[Python-Dev] PEP 3103: A Switch/Case Statement

Nick Coghlan ncoghlan at gmail.com
Thu Jun 29 14:23:18 CEST 2006

Greg Ewing wrote:
> Nick Coghlan wrote:
>> By 'current namespace' I really do mean locals() - the cell objects 
>> themselves
>> would be local variables from the point of view of the currently 
>> executing code.
> This is wrong. Cells are *parameters* implicitly passed
> in by the calling function. They may temporarily be
> referenced from the current scope, but their "home"
> has to be in an outer scope, otherwise they won't
> survive between calls.

As far as I'm aware, the cell objects get kept alive by the references to them 
from the closure attribute of the inner function. The actual execution frame 
of the outer function still goes away. The cell values persist because the 
function object persists between calls - it's only the execution frame that 
gets reinitialised every time.

However, I'm now clearer on the fact that Guido's main interest is in true 
once-per-process semantics for case expressions, which changes the design 
goals I was working towards.

So I think I'll try to take a break from this discussion, and let ideas 
percolate in the back of my head for a while :)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list