Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Marco Scheurer <email@hidden>
- Date: Mon, 19 May 2003 23:37:26 +0200
On Monday, May 19, 2003, at 09:32 PM, Martin Hdcker wrote:
At 13:19 Uhr -0400 19.05.2003, lbland wrote:
On Monday, May 19, 2003, at 12:30 PM, Martin Hdcker wrote:
As far as I know it's dispatching a method call on the type of both
the argument and the receiver, thus effectively doing the (almost >>> ...
...snip...
- do:(NSString *)aString;
Well... am I right on this? If so, what's the difference from the
effect created from name mangling?
your question can be interpreted in different ways, but here is one
answer:
...snip...
that is because obj-c does not mangle the name with type information
and any object cast (id <-> NSString * for example) is just a simple
pointer cast, less prototype resolution at compile time (no run time
resolution) which is an add on feature to obj-c (stepstone did not do
that in the original version).
Well, yes I get that. But what's the difference to this thing called
double dispatch that comes up from times to times?
This is how I understand all this is defined:
The right stuff is called "Multi methods", as implemented in CLOS, this
is a set of methods which is polymorphic on the receiver and the
arguments (in CLOS, they all look like arguments anyway). In CLOS,
selecting the method is done at runtime. Good.
When you don't have this, you can simulate "Double methods" using the
elegant "Double Dispatch" pattern. Instead of writing code that tests
(isKindOfClass:) for the argument's class, you send a message back to
the argument with self as parameter. Two messages allow you to select
using polymorphism twice. See Kent Beck's "Smalltalk Best Practice
Patterns" for more info (useful to Objective C programmers too!). Not
too bad.
And of course, in languages such as C++ or Java, you've got compile
time method and/or operator overloading, and name mangling is a
technique used to implement this. Bad.
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch
_______________________________________________
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.