multimethod (or rather overloading) in Python

Nick Coghlan ncoghlan at iinet.net.au
Sat Feb 19 21:43:55 EST 2005


anton muhin wrote:
> anton muhin wrote:
> 
> Correction:
> 
>> Of course, I can imagine some metaclasses magic that would allow to code:
>>
>> class MyClass(WithOverloading):
>>   @overloadMethod(A)
>>   def someMetod(self, _): ...
>>
>> But it would rather convoluted: the best idea I have so far is to 
>> mangle  methods name in the manner most of C++ compilers do.

PEAK has a fairly sophisticated implementation of method dispatch you may want 
to look at.

http://peak.telecommunity.com/Articles/WhatisPEAK.html
http://dirtsimple.org/2004/11/generic-functions-have-landed.html
http://peak.telecommunity.com/doc/src/dispatch/__init__.html

I'm compelled to point out that PEAK should still be considered a 'work in 
progress', but PJE's ideas should help you out :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list