[Python-Dev] Re: Re: closure semantics
aleaxit at yahoo.com
Sun Oct 26 05:37:40 EST 2003
On Sunday 26 October 2003 00:51, Greg Ewing wrote:
> > But what about name mismatches? Global statements allows functions to
> > create 'new' variables in the module scope and not just 'existing'
> > ones. What about for in-between scopes?
> It's probably a misfeature of the global statement that it allows
> that, but if we're going to re-use it in the form of a "global x in
> scope" statement, we should keep the behaviour the same for nested
> scopes in the interests of consistency.
> Maybe this is an argument for introducing an "outer" statement,
> which requires an existing binding (determined by existence of
> an assignment at compile time) even for the module scope, and
> deprecating "global" altogether.
I think Just's proposal of := meets all of these issues, too: it doesn't
have to, and won't, propagate global's misfeature of allowing creation
of new variables in nonlocal scope, and "requires an existing binding"
(and allows deprecating global altogether, with a warning in 2.4 etc)
in the most natural manner.
More information about the Python-Dev