[Python-3000] Draft pre-PEP: function annotations
Josiah Carlson
jcarlson at uci.edu
Sun Aug 13 06:16:18 CEST 2006
"Phillip J. Eby" <pje at telecommunity.com> wrote:
> However, if you have:
>
> def myfunc( x : doc("The x coordinate"), y : doc("The y coordinate") )
>
> There is no ambiguity. Likewise:
>
> def cat( infile:opt("i") = sys.stdin, outfile:opt("o") = sys.stdout ):
>
> is unambiguous. And the interpetation of:
>
> def cat(infile: [doc("input stream"), opt("i")] = sys.stdin,
> outfile: [doc("output stream"), opt("o")] = sys.stdout
> ):
>
> is likewise unambiguous, unless the creator of the documentation or option
> features has defined some other interpretation for a list than "recursively
> apply to contained items". In which case, you need only do something like:
>
> def cat(infile: docopt("input stream", "i") = sys.stdin,
> outfile: docopt("output stream", "o") = sys.stdout
> ):
I now understand where you were coming from with regards to this being
equivalent to pickle (at least pickle + copy_reg). I think that if you
would have posted this particular sample a couple days ago, there
wouldn't have been the discussion (argument?) about incompatible
mechanisms for annotation processing.
With that said, the above is a protocol. Just like __len__, __str__,
copy_reg, __reduce__, __setstate__, etc., are protocols. It may not be
fully specified (when annotations are to be processed, if at all, by
whom, where the annotation registry is, etc.), but it is still a
protocol.
Do we need any more specification for the PEP and 2.6/3k? I don't know,
maybe. You claim no, with the history of PEAK and other languages as
proof that doing anything more is unnecessary. And I can understand why
you would resist any further specification: PEAK has been doing
annotations for quite a while, and additional specifications could make
transitioning to these annotations a pain in the ass for you and your
users.
I'm personally not convinced that no further specification is desired or
necessary (provided we include a variant of the above example
annotations), but I also cannot convince myself that specifying anything
further would be flexible enough to not be a mistake.
- Josiah
More information about the Python-3000
mailing list