Multiple Dispatch

Delbert Murphy dmurphy at infratecture.com
Sat Jun 14 21:59:53 UTC 2003


Another good treatment of double-dispatch is GoF.  Check the Visitor pattern.

---- Original message ----
>Date: Sat, 14 Jun 2003 21:58:36 +0200
>From: Stephane Ducasse <ducasse at iam.unibe.ch>  
>Subject: Re: Multiple Dispatch  
>To: The general-purpose Squeak developers list <squeak-dev at lists.
squeakfoundation.org>
>
>Double-dispatch pattern
>
>I do not have a link at hand. Try google. It is used in Smalltalk to 
>define automatic coercion for number. I looked into Squeak but the code 
>on Integer, Float is a bit more complex and does not show the essence 
>of the pattern.
>
>Look in my slides at: 
>http://www.iam.unibe.ch/~ducasse/Web/Lectures/Lectures-OOP-0203/
>
>Stef
>
>
>On Saturday, June 14, 2003, at 08:25 PM, Joel Shellman wrote:
>
>> Has someone put in something to squeak to allow multiple dispatch? I 
>> thought
>> I heard this was not supported in Smalltalk in general, but is there
>> something in Squeak to do it?
>>
>> Thanks!
>>
>> -joel
>>
>>
>>
>> ----- Original Message -----
>> From: "Brian T Rice" <water at tunes.org>
>> To: "The general-purpose Squeak developers list"
>> <squeak-dev at lists.squeakfoundation.org>
>> Sent: Monday, June 09, 2003 2:04 AM
>> Subject: Re: Object: Identity vs. Environment
>>
>>
>>> I'm glad that someone eventually mentioned something related to 
>>> multiple
>>> dispatch. Slate's is: seems to work rather well for this case. ;)
>>>
>>> You can also override is: for ad hoc pretending on a pair of 
>>> arguments,
>>> and the original method is reallyIs: and is not overridden.
>>>
>>> On Mon, 9 Jun 2003, Joel Shellman wrote:
>>>
>>>> Ah, I think what you're referring to is double dispatch, isn't it?
>>>>
>>>> http://c2.com/cgi/wiki?DoubleDispatch
>>>>
>>>> Which so far as I understand it makes good sense.
>>>>
>>>> -joel
>>>>
>>>> ----- Original Message -----
>>>> From: "Andres Valloud" <sqrmax at comcast.net>
>>>> To: "The general-purpose Squeak developers list"
>>>> <squeak-dev at lists.squeakfoundation.org>
>>>> Sent: Monday, June 09, 2003 12:04 AM
>>>> Subject: Re: Object: Identity vs. Environment
>>>>
>>>>
>>>>>> But you might have a dozen methods with isFoo + ifTrue/ifFalse.
>>>>>> Then you would need Object>>fooAction1, Object>>fooAction2, etc.
>>>>>
>>>>> The dozen actions will get written one way or the other, either 
>>>>> inside
>>>>> ifTrue/ifFalse blocks or in messages.  As far as the amount of code 
>>>>> is
>>>>> concerned, fooActions are at least as compact - if not more since 
>>>>> you
>>>>> don't need ifTrue/ifFalse.
>>>>>
>>>>> The key issue here is that the ifTrue/ifFalse actions should be in
>>>>> messages the receivers of isXYZ understand.  Otherwise, the context 
>>>>> in
>>>>> which you write the ifTrue/ifFalse actions has to grow larger to
>> provide
>>>>> meaning to the actions.  You end up as if you had used a traditional
>>>>> programming language: the receivers of isXYZ are more value holders
>> than
>>>>> behaviorful distinctions as far as the context of usage is 
>>>>> concerned.
>>>>>
>>>>> Disclaimer: these arguments apply only to the "isKindOf:" kind of
>> isXYZ
>>>>> messages.
>>>>>
>>>>> Andres.
>>>
>>> -- 
>>> Brian T. Rice
>>> LOGOS Research and Development
>>> http://tunes.org/~water/
>>>
>>
>>
>
>



More information about the Squeak-dev mailing list