sentTo: broken, was Re: Proxy Design Pattern and Squeak
Roger Whitney
whitney at cs.sdsu.edu
Wed May 10 03:04:57 UTC 2000
>> In his example, the proxy is for a Customer object. The proxy overrides
>>doesNotUnderstand:.
>>Here's the code.
>>
>>doesNotUnderstand: aMessage
>> |customer|
>> customer := "materialize the customer".
>> self become: customer.
>> ^aMessage sendTo: self. "redispatch!"
>>>
>Just a slight difference in dialects here. In Squeak you could say:
>
> ^aMessage sentTo: self
>or
> ^self perform: aMessage selector withArguments: aMessage arguments
The two are currently not the same in Squeak. The former does not work (Yes
I tried it in 2.7) while the later does work. The problem is in the
implementation of sentTo:. We have:
sentTo: receiver
lookupClass == nil
ifTrue: [^ receiver perform: selector withArguments: args]
ifFalse: [^ receiver perform: selector withArguments: args
inSuperclass: lookupClass]
Asume we are using the above proxy code with sentTo: When sentTo: method is
run the receiver is the customer object and the lookupClass is the Proxy
object. So the ifFalse: block is run. So the only way this would work is
to have the proxy as a superclass of customer. But then we would create an
infinite loop, as the receiver tries to have the superclass execute the
method, which calls the doesNotUnderstand method in the proxy.....
The example in the class comment of ObjectTracer is also broken due to the
sentTo: method in Message.
Roger Whitney Mathematical & Computer Sciences Department
whitney at cs.sdsu.edu San Diego State University
http://www.eli.sdsu.edu/ San Diego, CA 92182-7720
(217) 328-0824
(619) 594-3535
(619) 594-6746 (fax)
More information about the Squeak-dev
mailing list
|