• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Future Objective-C changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Future Objective-C changes
      • From: Dietrich Epp <email@hidden>
References: 
 >Re: Future Objective-C changes (From: Dietrich Epp <email@hidden>)

  • Prev by Date: Re: Future Objective-C changes
  • Next by Date: Notification received twice
  • Previous by thread: Re: Future Objective-C changes
  • Next by thread: Re: Future Objective-C changes
  • Index(es):
    • Date
    • Thread