4 ms·
This technique is limited by the fact that it only works if all the messages are sent to x, rather than x being sent some message.
by taejo 10y ago
This technique is limited by the fact that it only works if all the messages are sent to x, rather than x being sent some message.
- pg314 10y agoYou mean "rather than x being sent to some message"? E.g. 0 > x wouldn't work, because the message #> is sent to 0 with x as an argument? In a case like that you can still make it work by exploiting the fact that arithmetic and comparison operators implement double dispatch. The implementation of > for an Integer would send a message to x: Integer::> aNumber ^x adaptToInteger: self andCompare: #< Even if x is passed as an argument, to interact with it at some point somebody has to send a message to it. I agree that it can become unwieldy to intercept all possible messages, but for a well-defined subset in your DSL, this can usually be done.
- taejo 10y agoThanks! I didn't consider the fact that objects are opaque.