Typed Systems, Type Inference, etc
Joshua 'Schwa' Gargus
schwa at cc.gatech.edu
Sun Jul 21 19:06:04 UTC 2002
On Sun, Jul 21, 2002 at 01:05:58PM +0200, Diego Gomez Deck wrote:
> >NOTE: Both forms shown here (original form, classic Smalltalk form) will
> >compile and produce the exact same code and behavior. With the noted
> >comments where I removed some extra annotations and replaced them with
> >comments.
>
> In ST you can write code like that:
>
> Point>>+ anObject
> ^ anObject addToPoint: self.
>
> Point>>addToPoint: aPoint
> ^ (self x + aPoint x) @ (self y + aPoint y)
>
> Number>>addToPoint: aPoint
> ^ (self + aPoint x) @ (self + aPoint y)
>
> String>>addToPoint: aPoint
> ^ (self asNumber + aPoint x) @ (self asNumber + aPoint y)
>
> My point is: The gain don't pay the complexity added to the language.
The double-dispatch pattern works fine if you are only dispatching on
two types. However, if you are dispatching on 3 or more, it is much
nicer to have real multi-method dispatch.
Joshua
More information about the Squeak-dev
mailing list
|