Previous Entry Share Next Entry
02:56 am, 10 Apr 05


Hot on the heels* of my post about hip languages and encroaching types, GvR writes about multimethods in Python, defining them as "a function that has multiple versions, distinguished by the type of the arguments".

I think the more pedantic definition is that they vary on the run-time type of the arguments. (But as I understand Python, that's the only sense of type that exists...) For example, you can already implement the example multimethods code he's written in multimethod-less C++.

The group I almost got involved in at UW was always doing research with multimethods. Random Python talk mentions the Chambers and Chen algorithm, and I was briefly in Chambers' advanced compilers class...

But I never looked into multimethods too hard 'cause they pretty much give me the heebie-jeebies. I wonder if it's just the way I've been trained to think; the canonical examples (overriding the 2d-point add method with one specialized for a pair of 3d points that adds their z coordinate) make sense, sorta. I think all of the ML has also warped my brain away from thinking about everything in terms of objects anyway.

* Actually preceding by a few days, but I just saw it.