I am trying to modify a multipoint GUID (dynamic dispatch code):
http://www.artima.com/weblogs/viewpost.jsp?thread=101605
to handle inheritance arguments and possibly out of order.
eg. (inheritance problem)
class A(object): pass class B(A): pass @multimethod(A,A) def foo(arg1,arg2): print 'works' foo(A(),A())
Is there a better way than iteratively checking the super () of each element until it is found?
eg. (problem of ordering arguments) I thought about this in terms of collision detection.
eg.
foo(Car(),Truck()) and foo(Truck(), Car()) and
should run
foo(Car,Truck)
I am looking specifically for an โelegantโ solution. I know that I could just lay my way on all the possibilities, but I try to avoid this. I just wanted to get some ideas / ideas before I sat down and beat up the solution.
thanks
source share