[Python-3000] Use cases for type annotations? (WAS: Type parameterization)
Phillip J. Eby
pje at telecommunity.com
Sun May 21 18:32:38 CEST 2006
At 02:44 PM 5/21/2006 +0100, Paul Moore wrote:
>Maybe just having a single "blessed" implementation of a function
>overloading module in the stdlib (even in the 2.x series) would be the
>best place to start. With a bit more real-world experience, it would
>be easier to see if there was call for integrating the concept more
>deeply into the core.
2.5 actually includes a single-dispatch overloading function already,
although it's internal to pkgutil and not exposed for anything else to use.
The Overload3K prototype was mainly intended to promote:
1. having a "defop" keyword to allow anonymous overloading using argument
annotations
2. having an extensible builtin overload() that's able to:
a) overload builtins using Python's existing method dispatch machinery
b) overload any other type you want to use as an "overloaded function"
(so that advanced or specialized implementations are still first class)
3. having one or more extensible 'implies()' functions that can be shared
by overloaded function implementations and thus extended to allow new kinds
of argument criteria.
4. having a standard protocol for introspecting the methods available in
overloaded functions, so that overloaded functions *themselves* can be used
as simple typeclasses or interfaces. (That way, you could define something
like 'def join(sep:str, seq:iter)' and have the 'seq' argument accept any
type that implements __iter__.)
More information about the Python-3000
mailing list