• 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: why Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why Obj-C


  • Subject: Re: why Obj-C
  • From: Marcel Weiher <email@hidden>
  • Date: Tue, 9 Apr 2002 14:36:31 +0200

On Tuesday, April 9, 2002, at 12:32 Uhr, Ondra Cada wrote:
On Tuesday, April 9, 2002, at 03:28 , John C. Randolph wrote:
foo = [[MyClass alloc] initWithSomeOtherObject:[OtherClass randomObject]];

foo=MyClass->alloc()->initWithSomeOtherObject(OtherClass->randomObject())
;

Sure, this works, but let's see what the good doctor has to say on this subject:

"Most C programmers would never dream of writing deeply nested function calls like this:

printf("(%d,%d)\n",xCoord(originOf(aRectangle)), yCoord(cornerOf(aRectangle)));

But oddly, they quickly become accustomed to doing the same thing with message expressions:

printf("(%d,%d)\n",[[aRectangle origin] x], [[aRectangle corner] y]);

"

I find this observation to be exactly on the mark. Yes, it is probably odd at first, but for some reason the Objective-C syntax seems to allow more complex expressions to be handled more clearly, similar to the way that Objective-C allows us to handle greater program complexity more clearly.

And a general commnt on the keyword syntax ( do: something with: otherThing )

"This convention seems strange to those accstomed to conventional functional call syntax, and frankly, I find it a mixed blessing. It does provide tight syntactic control over the number and meaning of method argumnts, and it does lead to surprisingly readable code, once you've become accustomed to the new conventions. But it is hard to explain, and the keyword notion is superficial in that the keyword fragments are immediately joined in the compiler and dealt with tehereafter as a single concatenated string. It has the definite disadvantage of making it more difficult to locate messages in source code by searching for a simple string, because arguments inside the keyword get in the way of string searching tools"

Both quotes from "Object Oriented Programming: An Evolutionary Approach" by Brad J. Cox, Ph.D., Addison-Wesley, pps. 56-57

Marcel

--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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: why Obj-C
      • From: Thomas Lachand-Robert <email@hidden>
    • Re: why Obj-C
      • From: Ondra Cada <email@hidden>
References: 
 >Re: why Obj-C (From: Ondra Cada <email@hidden>)

  • Prev by Date: Robert and John: copyPath and Unix permissions.
  • Next by Date: Re: why Obj-C
  • Previous by thread: Re: why Obj-C
  • Next by thread: Re: why Obj-C
  • Index(es):
    • Date
    • Thread