[Python-3000] What's the point of annotations?
Phillip J. Eby
pje at telecommunity.com
Wed Jan 3 19:05:31 CET 2007
At 11:06 AM 1/3/2007 -0600, Collin Winter wrote:
>I don't see annotations and decorators as falling in to the same
>category in that respect. Decorators make life easier for a much wider
>audience than do annotations. Everyone uses decorators, but how many
>people write/use Java/ObjC bridges?
Um, everybody using Jython or programming OS X with Python? Also, now that
you remind me of it, IronPython could use 'em for C# overloads.
>Predicate logic functions?
Take a look at the number of cookbook recipes out there.
>RPC
>parameter marshaling?
If annotations were available in 1996, Zope would likely have been using
them for this (even though the word "Zope" didn't exist yet). Annotating
argument types on the function side is far more elegant than annotating
them in the HTML form field names.
>Maybe I'm wrong, though. A serious question to anyone doing a lot of,
>e.g., RPC work: will annotations make your life easier? In what way?
Ask the folks working on *any* sort of foreign language bridging, who were
also a major voice in some of the decorators discussion.
>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. :) Note, however, that Java
annotations (the place we stole the "@" sign from) can be applied to
arguments as well as to methods and classes, and they *already* have the
type information without needing annotations! So, you might look to see
what *else* they use it for, besides documentation and IDE hints. I
haven't done any Java work in a long time, myself.
(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.)
More information about the Python-3000
mailing list