Typed Systems, Type Inference, etc

Diego Gomez Deck DiegoGomezDeck at ConsultAr.com
Sun Jul 21 13:31:14 UTC 2002


Hello,

> > Point>>+ otherPoint
> >
> >         ^(self x + otherPoint x) @ (self y + otherPoint y)
> >
> > The only requirement for otherPoint is to answer #x and #y messages [*].
> >
> > [*] Answer a message don't means implement a method. Example: a object
> > using #doesNotUnderstand: can answer to several messages without a method.
>
>I was suprised to see Squeak bothering to cast a number into a point like
>1 at 2 + 3 --> 1 at 2 + (3 at 3). What's wrong with just making a more specific
>version of a method, and playing games with polymorphism?

Actually Squeak can handle adding Points, Numbers, Strings and Collections.

Examples:

     1 at 2 + 3 -> 4 at 5
     1 at 2 + '5' -> 6 at 7
     1 at 2 + '5 at 3' -> 6 at 7
     1 at 2 + {3 at 4. 5 at 6} -> #(4 at 6 6 at 8)
     1 at 2 + {3. 5} -> #(4 at 5 6 at 7)

The same for messages: #*, #-, #/, #// and #\\

Cheers,

Diego Gomez Deck





More information about the Squeak-dev mailing list