P.J. Eby wrote:
> At 06:28 AM 3/16/2009 +1000, Nick Coghlan wrote:
>> There are some practical hurdles to that idea (specifically, creating a
>> callable which uses its parent's namespace rather than having its own),
>> but the basic concept seems sound.
> 
> Actually, that bit's pretty simple -- they're just "nonlocal"
> variables.  But the cost of creating that function, and the cost of
> having cell variables in the surrounding function is potentially high. 
> (In CPython at least, function calls are optimized in certain ways when
> the function only has "fast" locals, and no "cell" locals.)

Some additional complexities occurred to me today - they go by the names
"return", "break" and "continue". With the current design those are
perfectly well defined inside a with statement, but they pose a pretty
serious hurdle for a practical implementation of glyph's idea.

So I'm going to stick with the more modest approach of a new control
flow exception for PEP 377.

I still find the callable block idea somewhat intriguing, but if it ever
happens it should be a new construct rather than overloading the meaning
of the with statement.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to