[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
python at mrabarnett.plus.com
Wed Sep 28 18:24:47 CEST 2011
On 28/09/2011 16:58, Paul Moore wrote:
> On 28 September 2011 16:38, Guido van Rossum<guido at python.org> wrote:
>> Of course once there's different syntax, the nonlocal declaration in
>> the function is redundant. And clearly I'm back-peddling. :-)
> If we're back to syntax proposals on the def statement, how about
> def fn() with i=1, lock=Lock():
> ? This is basically another bikeshed to paint, though...
I'd already arrived at the same solution! :-)
The complaint about putting "static" or "own" in the body of the
function is that it's not clear that it's evaluated at definition time.
The complaint about putting it outside the function is that it's not
clear that the name is visible only inside the function (and it's also
harder for the compiler to recognise it and optimise for it).
The only place where the expression can be evaluated at definition time
and bound to a name which is visible only inside the function is in the
We don't want it in the parameter list, therefore it can go after the
More information about the Python-ideas