[Python-3000] PEP 3124 - more commentary
Guido van Rossum
guido at python.org
Tue May 15 17:32:02 CEST 2007
On 5/15/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> 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:
> def range(*args:3):
> 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.
> Still good?
Not so good; I expect the overloads could be written by different
authors or at least at different times. Why can't you dynamically
update the dispatcher when an overloading with more arguments comes
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000