[Twisted-Python] Generic functions using PyProtocols (was Re: Components)

Phillip J. Eby pje at telecommunity.com
Sat Feb 28 09:01:09 MST 2004


At 12:21 AM 2/28/04 -0500, Christopher Armstrong wrote:

>Wow. glyph explained to me what he wanted before with the no-instantiation 
>IFoo.meth(x), but I didn't realize that it really _is_ like generic 
>functions. That's awesome. :-)

Well, a generic function with a couple of interesting twists, like being 
able to say that a particular signature is based on a protocol rather than 
a specific class, with transitive adaptation taking place.  So, if the 
closer adaptation path is that the object gets adapted to an interface you 
support, then that's what you'll get passed to the function.

The other twist is that you can create a new generic function, and then 
declare that it is "implied by" another generic function.  You'll then 
"inherit" all of the definitions from the old generic function, allowing 
you to then just override certain specific implementations of the function 
in your new function.





More information about the Twisted-Python mailing list