[Python-3000] Draft pre-PEP: function annotations

Jim Jewett jimjjewett at gmail.com
Sun Aug 13 07:29:52 CEST 2006


On 8/13/06, Josiah Carlson <jcarlson at uci.edu> wrote:

> "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.

Sure there is.  There will probably be several frameworks using the
magic name "doc".

This isn't a problem for the person writing myfunc, and therefore
isn't a problem for immediate decorators.  It is a problem for
inspection code that wants to present information about arbitrary
3rd-party libraries.

And once you get into multiple annotations, there will be some
frameworks that say "the doc annotation is mine, I'll ignore the opt
annotation" and others that say "oh, a dictionary of annotations, I
need to do this with name doc and that with name opt"

And of course, people won't really write doc("The x coordinate")
unless they're already thinking of other uses for a string; they'll
just write "The x coordinate" and someone later (perhaps from a
different package) will have to untangle what they meant -- short
expressions will end up being ambiguous almost from the start.

Eventually, ways will be found to sort things out.  But there will be
less pain and backwards incompatibility if these issues are considered
from the start.


> 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.

The history of complaints about PEAK being hard to understand and
inadequately documented suggests that a fair number of people would
prefer additional guidance and handholding.  If annotations could only
be used safely by people who can understand PEAK, then offering
syntactic sugar to everyone would be asking for trouble.

-jJ


More information about the Python-3000 mailing list