[Python-3000] Fwd: Conventions for annotation consumers
Phillip J. Eby
pje at telecommunity.com
Wed Aug 16 02:17:29 CEST 2006
At 05:29 PM 8/16/2006 -0500, "Collin Winter" <collinw at gmail.com> wrote:
>On 8/15/06, Calvin Spealman <ironfroggy at gmail.com> wrote:
> > On 8/15/06, Collin Winter <collinw at gmail.com> wrote:
> >> 1) Static analysis tools (pychecker, optimising compilers, etc) must
> >> be able to use the annotations
> > As in any example given so far, the annotations would be instansiated
> > within the function definition itself, which means the form 'def
> > foo(a: Bar(baz))' is to be expected. This form could even be
> > documented as the prefered way, as opposed to instansiating the
> > annotation object before hand and simply using its name in the
> > function definition. This leads to simple parsing by external tools,
> > which would be able to deduce what bar is (because before that line
> > there was an 'from bar import Bar'.
>How exactly do they "deduce" what Bar is, just from the "from bar
>import Bar" line? pychecker would have to import and compile the Bar
>module first. What if being able to import bar depends on some import
>hooks that some other module (imported before bar) installed? I guess
>you'd have to follow the entire import graph just to make sure. Oh,
>and you'd have to end up running the module being analysed in case
>*it* installs some import hooks -- or maybe it defines Bar itself.
>Your proposal isn't workable.
By that logic, neither is Python. :)
I think you mean the reverse; the proposal instead shows that requirement
#1 is what's not workable here.
I'm frankly baffled by the amount of "protect users from incompatibility"
ranting that this issue has generated. If I wanted to use Java, I'd know
where to find it. Guido has said time and again that Python's balance
favors the individual developer at the expense of the group where
"consenting adults" is concerned, and Py3K isn't intended to change that
Personally, I thought Guido's original proposal for function annotations,
which included a __typecheck__ operator that was replaceable on a
per-module basis (and defaulted to a no-op), was the perfect thing --
neither too much semantics nor too-little. I'd like to have it back,
More information about the Python-3000