Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Gerard Iglesias <email@hidden>
- Date: Wed, 21 May 2003 08:35:48 +0200
On Tuesday, May 20, 2003, at 10:14 PM, Dietrich Epp wrote:
The problem with C++ automagic name mangling is that it makes for
unexpressive names. This manifests itself well with the constructor
functions:
class Quaternion {
public:
Quaternion (float w, float x, float y, float z);
Quaternion (float x, float y, float z, float a);
};
I have two constructors that each take four floating-point numbers!
The first one creates a quaternion from its components, and the second
creates one from an axis and and angle. The reason C++ behaves this
way is that lazy naming (Quaternion(...) vs.
QuaternionWithComponents(...)) worked its way into standard usage.
Think this shortcut wouldn't kill Objective C? Think again:
I was involved in a big C++ project almost ten years ago, but having
coded in ObjC before, I switched quickly to do the following :
class Quaternion
{
public
Quaternion();
~Quaternion();
virtual Quaternion * initWithCoordinate(float w, float x, float y,
float z);
virtual Quaternion * initWithAxixAndAngle(float w, float x, float y,
float a);
}
then an object is created by I believe ?
Quaternion * q = (new Quaternion())->initWithCoordinate(1,1,1,1);
In fact we ended in building a sort of clone of Foudation/AppKit in
ObjC ;) With a tree of class with a common superclass in order to build
almost untyped things with array, dict, archiving, .... like OpenStep
:) It was funny.
Ok, ok, I make full time ObjC dev for two years now, I almost forgot
the C++ existence ;)
@class Matrix
-(Vector *)multiplyBy:(Vector *)vector;
-(Matrix *)multiplyBy:(Matrix *)matrix;
-(Matrix *)multiplyBy:(float)scalar;
@end
and what about :
@class Matrix
- (Vector*)multiplyByVector:(Vector*)v;
- (Vector*)multiplyByMatrix:(Matrix*)v;
- (Vector*)multiplyByScalar:(float)v;
@end
Best regards
Gerard
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.