|
![](/i/fill.gif) |
>> Works great, as long as they're the same type. Try swapping an array of
>> integers with a socket.
>
> Wouldn't it break the code which expects the object to be an array, but
> the object gets suddenly changed to something completely different?
One would presume so, yes. Depends what you decide to replace it with.
> (What does Smalltalk do when an inexistent method is called? Runtime error?
> That's at least what happens in Objective-C, which is based on the same
> principles as Smalltalk, IIRC.)
Does calls #doesNotUnderstand:, which is a regular method. BY DEFAULT
this throws an exception, but you can override it to do... whatever you
want.
Darren's original article describes using it to load objects from disk
the first time somebody tries to access them, for example.
I saw somebody else describe overriding it to implement multiple
dispatch. (Smalltalk itself supports only single dispatch, like most OO
languages.)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |