This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Multimethods in VW
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Someone I've not had the chance to talk to yet has added Multimethods as a new package to the public store for VW. It's an interesting idea, being able to switch methods based on the types of arguments passed in. In the same token, it is limited because you cannot really programmatically test each argument to switch methods in a simple way.
What I want to say to the author is this: If class 'A' implements printOn: aStream and I extend it to include printOn_withFooBar: aStream, the original method will pick up the call and the DNU will not see it.
How can this be worked around? Well, to tell you the truth, I'm not sure it can. You could add a stack manipulator into the printOn: to check for multimethods and adjust the stack accordingly instead of running the code it has. That'd be a simple one line insertion in to the printOn: method, such as 'self adjustForMultimethods.'. Or you could do a #perform: like action from the sender side, that would check for multi methods before committing to the selector it's going use.
Either solution isn't so nice IMHO.
Interesting idea though. I'm not a big fan of the explicit implementation he's ended up with thus far. But keep the interesting ideas rolling in :)