Bug Involving Modified #to:by:do:

Tim Olson tim at jumpnet.com
Sun Jan 31 14:59:51 UTC 1999


>5.6.2.39 Message: to: stop by: step do: operation
>. . .
>Definition: <number>
>. . .
>The elements must all conform to either the receiver's or step's protocol,
>according to the Default Conversion Table.

Interesting; I hadn't looked in detail at this area of the spec, but I 
agree with your interpretation of it.

To do this, it looks like you will have to implement a new 
double-dispatch message in each of the primary Number subclasses, 
paralleling the binary arithmetic messages and using the existing 
adaptTo:andSend: messages, e.g.:

Integer>>adaptTo: aNumber

     ^ aNumber adaptToInteger: self andSend: #yourself:


Float>>adaptTo: aNumber

     ^ aNumber adaptToFloat: self andSend: #yourself:


where #yourself: is a new keyword message in Object, which, just like 
#yourself, does nothing but return "self" (and ignores its argument).

The "yourself:" stuff seems kind of superfluous, but allows you to 
piggyback on the existing coersion mechanisms without having to write a 
whole new set that just adapts without sending a binary message.




     -- tim





More information about the Squeak-dev mailing list