[Python-3000] Implementations: A syntax for extending method dispatching beyond type/class inheritance

Dave Anderson python3000 at davious.org
Mon Dec 4 03:43:29 CET 2006


I'd like to augment one of the sections to my previous post...
was: An Implementation can be a combination of
Classes and Class Methods

I meant to say: An Implementation can be a combination of
Classes, Class Methods, and Other Implementations


An Implementation can be a combination of
Classes, Class Methods, and Other Implementations
=================================================

A_B_C_like = Implementation(A, B, C.f, C.g)

class D:
     implements A_B_C_like
     ...

def f(A_B_C_like_arg: A_B_C_like):
# will dispatch D instances
     ...


implementations can be composed of other implementations
--------------------------------------------------------

A_B = Implemenation(A, B)

A_B_C_like = Implementation(A_B, C.f, C.g)


informal implementation lists are also allowed
---------------------------------------------

class D1:
     implements A, B, C.f, C.g
     ...

def f(A_B_C_like_arg: A, B, C.f, C.g):
# will dispatch D and D1 instances
     ...

multiple implementation declarations are also allowed
-----------------------------------------------------

class D2:
     implements A, B
     implements C.f, C.g

def f(A_B_C_like_arg: A, B, C.f, C.g):
# will dispatch D, D1, and D2 instances
     ....


More information about the Python-3000 mailing list