[Python-3000] PEP 3124 - more commentary
Phillip J. Eby
pje at telecommunity.com
Tue May 15 17:07:44 CEST 2007
At 09:43 PM 5/14/2007 -0700, Guido van Rossum wrote:
>On 5/14/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> > Or perhaps we could just say that if the main function is defined
> > with *args, we treat those arguments as positional? i.e.:
> > @abstract
> > def range(*args):
> > """This just defines the signature; no implementation here"""
>That sounds about right.
After thinking about the implementation some more, I believe it'll be
necessary to know *in advance* the maximum size of *args that will be
used by any subsequent overload, in order to both generate the
correct code for the main function (which must construct a fixed-size
lookup tuple containing special values for not-supplied arguments),
and the correct type tuples for individual overloads (which must
contain similar special values for the to-be-omitted arguments).
So, if we could do something like this:
then that would be best. I propose, therefore, that we require an
integer annotation on the *args to enable positional dispatching.
If there are more *args at call time than this defined amount, only
methods that have more positional arguments (or a *args) will be selected.
If the number is omitted (e.g. just *args with no annotation), the
*args will not be used for method selection.
More information about the Python-3000