Statement local namespaces summary (was Re: python3: 'where' keyword)

Nick Coghlan ncoghlan at iinet.net.au
Tue Jan 11 04:42:24 EST 2005


Nick Coghlan wrote:
> Semantics
> ---------
> The code::
> 
> <statement> with:
>    <suite>
> 
> translates to::
> 
> def unique_name():
>     <suite>
>     <statement>
> unique_name()
> 

Bleh. Not only was my proposed grammar change wrong, my suggested semantics are 
wrong, too.

Raise your hand if you can see the problem with applying the above semantics to 
the property descriptor example.

So I think the semantics will need to be more along the lines of "pollute the 
namespace but mangle the names so they're unique, and the programmer can *act* 
like the names are statement local".

This will be much nicer in terms of run-time performance, but getting the 
locals() builtin to behave sensibly may be a challenge.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list