Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message forwarding with doesNotUnderstand in Smalltalk

I had a query about redefining the message doesNotUnderstand: in smalltalk. What I want to do is to forward all the messages received by an object that are not understood, to another object that it has in its knowledge. My problem comes from the fact that both objects (both the receiver and the one that forwards) have the same protocol inherited by the super class and when the message is not understood by the specific protocol of the object but if it is understood by the inherited protocol, it executes the message inherited and not the doesNotUnderstand: (so the message is not forwarded and the super class message is invoked).

I really appreciate the help, regards!

like image 947
Iyael Avatar asked Jan 24 '23 23:01

Iyael


1 Answers

As I understand it, you have a situation in which you want to forward a message but it is understood by the one that forwards (we call that a proxy object) so doesNotUnderstand: is not being invoked in the proxy.

You have two possible solutions. First (and in general), a proxy object should inherit from ProtoObject so as to avoid inheriting any default behavior. But if this is not a true proxy object (that passes along essentially everything), then you need to override the messages that should be forwarded and call doesNotUnderstand: (or your forwarding code) directly.

like image 99
James Foster Avatar answered Jan 31 '23 20:01

James Foster