[Python-ideas] [Python-3000] PEP 3107 Function Annotations: overloadable ->
jcarlson at uci.edu
Tue Jan 2 07:34:41 CET 2007
Tony Lownds <tony at pagedna.com> wrote:
> On Jan 1, 2007, at 5:39 PM, Josiah Carlson wrote:
> > Given a reading of version 53169 of PEP 3107, I see no reason to even
> > offer a __returns__ attribute, automatic method call, etc. PEP 3107
> > already defines the annotation to be specified as a dictionary of
> > named
> > argument names, with a key of 'return' for the annotation of the
> > return
> > annotation. Is there any reason why this isn't sufficient?
> > Even in the context of the signature PEP 362, there is no need for
> > __returns__, as an annotation-consuming library would check the
> > signature object for argument annotations, and the func_annotations
> > dictionary for the 'return' key for any return annotations.
> Something got lost in the movement between lists... __returns__ wasn't
> going to supplant or alter func_annotations or PEP 362 in any way.
> __returns__ was proposed as the special method attached to a new
> operator (->). That operator could be used to write expressions that
> like a function signature.
> Here's Kay's original email.
-1 on the -> operator as specified in the email you link. There is no
reason to add aribtrary operators for call-site annotations. PEP 3107
has already defined the syntax for function definition site annotations
def name(argument=default:annotation) -> annotation:
While PEP 3107 has not been formally accepted (according to the web page),
the ideas contained received general approval from more or less everyone
involved in the py3k discussion, or at least more or less everyone who
has written and/or consumed annotations in the past.
The mail you link, talks about an arbitrary -> operator for call-site
annotations. Without seeing actual use-cases where a -> operator would
be useful in the real-world, I can't help but be -1 on the -> operator
and -1 on the __returns__ method.
Use-case(s) before syntax and semantics,
More information about the Python-ideas