• 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: Ondra Cada <email@hidden>
  • Date: Tue, 9 Apr 2002 12:32:35 +0200

On Tuesday, April 9, 2002, at 03:28 , John C. Randolph wrote:

Back when I first learned Obj-C, I was of the opinion that C++'s method call syntax was better(which it's not) because it was more in the style of C (which it is). What changed my mind was realizing that Obj-C expressions can *nest*, as in:

foo = [[MyClass alloc] initWithSomeOtherObject:[OtherClass randomObject]]
;

You can construct something similar, though ugly (well, in *my* opinion those dots/arrows are ugly _anywhere_):

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

IMHO though there is an EXCELLENT reason to use [...]: the dot serves for _accessing entrails of structs_. Therefore it is quite right that C++ (and even Java) uses it, since its "methods" are, in fact, just functions stored in structs, and nothing more (which applies to virtual ones as well)
.

Though, we *ARE NOT* accessing anything: we are *SENDING MESSAGES* instead.
That is an utterly new thing, absolutely unknown in any other C-based language (so far as I can say), and utterly DIFFERENT from accessing any struct! Therefore it very definitely deserves a specific language construction.

It can be argued whether [...] are optimal or whether, I dunno, something like

@SEND(target, message)

might appeal more to some users (again, not to me, I personally find [...] an excellent solution), but for the aforementioned reason I think that dots (or ->s) would be very very definitely wrong.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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: "David W. Halliday" <email@hidden>
    • Re: why Obj-C
      • From: Marcel Weiher <email@hidden>
References: 
 >Re: why Obj-C (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: zooming graphic
  • 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