Re: why Obj-C
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.
References: | |
| >Re: why Obj-C (From: "John C. Randolph" <email@hidden>) |