[Python-3000] What's the point of annotations?

Phillip J. Eby pje at telecommunity.com
Wed Jan 3 21:12:48 CET 2007


At 01:00 PM 1/3/2007 -0600, Collin Winter wrote:
>On 1/3/07, Phillip J. Eby <pje at telecommunity.com> wrote:
>>At 11:06 AM 1/3/2007 -0600, Collin Winter wrote:
>> >PS: I think it's interesting how nearly all the use-cases mentioned
>> >involve adding type information to functions.
>>
>>Um, yeah, that was kind of the idea.  :)
>
>I mention that as an amusing contrast to the "you could use
>annotations for *anything*!" tone of the latter discussions and the
>PEP.

I would guess that's because you're thinking "type" means "Python type 
object", which is a significantly narrower concept than is being talked 
about here.


>I've never done any serious Java work, but the examples Google has
>turned up seem to focus on working around limitations in Java's
>reflection and type systems. What were you thinking of?

Java annotations came in "after my time", so to speak.  I don't have 
anything specific in mind, I just know they exist and I gather they are used.


>>(The problem with your approach to this, though, is that basically you
>>still just keep complaining that each use case could be done some other
>>way.  Of course they can.  That's not the point.  Might as well argue that
>>we don't need both mappings *and* objects with attributes, because
>>JavaScript gets by with combining the two.)
>
>No, my point is that not every n-line function needs to be made into syntax.

Um, okay, but that has nothing to do with annotations.  :)

We added decorator syntax to move their declaration closer to the target 
and eliminate some duplication.  This is exactly the same; it's to improve 
clarity for the *reader* of the code, at least as much as it is a 
convenience for the writer of it.



More information about the Python-3000 mailing list