Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Dietrich Epp <email@hidden>
- Date: Wed, 21 May 2003 16:45:06 -0700
On Tuesday, May 20, 2003, at 23:35 US/Pacific, Gerard Iglesias wrote:
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);
That doesn't work because I often need the thing allocated on the stack
or as a member variable. Also, if this were to be rewritten to allow
it to work statically allocated, then you'd have to explicitly call a
bunch of allocation routines... and suddenly you're writing glorified C.
But the point is that with overloading and lazy names, methods which
should be crystal clear are now muddled and you have to examine the
documentation to figure out what they do. If you write more
descriptive method names then you're basically ignoring overloading.
_______________________________________________
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.