[Python-3000] PEP 3124 - more commentary (original) (raw)
Phillip J. Eby pje at telecommunity.com
Tue May 15 17:07:44 CEST 2007
- Previous message: [Python-3000] PEP 3124 - more commentary
- Next message: [Python-3000] PEP 3124 - more commentary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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:
@abstract
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?
- Previous message: [Python-3000] PEP 3124 - more commentary
- Next message: [Python-3000] PEP 3124 - more commentary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]