[Python-3000] Sky pie: a "var" keyword
Neil Toronto
ntoronto at cs.byu.edu
Wed Oct 11 04:51:12 CEST 2006
Nick Coghlan wrote:
>> The only sane proposal i've seen that consistently addresses all
>> these cases, doesn't create new ambiguous situations, and doesn't
>> break most existing Python code is the "nonlocal" declaration.
>>
>> nonlocal x
>>
>> means
>>
>> "Don't make a new binding for x in the local scope."
>>
>> With this declaration, any binding statements modify the x that
>> is visible from an outer scope instead of creating a local x.
>>
>
> Agreed - I believe the only real problem with the idea was that nobody could
> come up with a name for this statement that was clearly the right name.
>
> Re-using 'global' wasn't popular because it would actually be *wrong* for the
> new semantics (the name might not be right), and other contenders like 'outer'
> and 'nonlocal' had their share of critics, too ('outer' isn't quite right
> because the name used is rebound in the innermost lexical scope that defines
> it, while 'nonlocal' had the problem of being a negative definition). Jeremy
> Hylton provided a nice list of the goals for a good choice of keyword [1]
> ('global' failed criteria #2, whereas 'nonlocal' passed criteria #2 but failed
> the rest).
>
From what I can see, you could object to *every* keyword on the grounds
that the name is rebound in the innermost lexical scope: nonlocal (it's
not, it has a local binding), outer (it's really inner), and external
(nope, it's internal) all have this problem.
For me, +1 on "outer" because it has the fewest syllables and
characters, and accurately describes the semantics (minus the rebinding,
which every keyword lies about) without baggage from any other language
I know of.
I also like "outie," but I'm weird like that.
So is the reason a PEP was never drafted because nobody could agree on
the word? It seems like the name should be subject to the standard
Pythonic way of doing this: draft a PEP with candidates, vote on them,
and then Guido will disregard the voting results and pick the one he
likes. :D
Neil
More information about the Python-3000
mailing list