Statement local namespaces summary (was Re: python3: 'where' keyword)
Andrey Tatarinov
elephantum at dezcom.mephi.ru
Tue Jan 11 05:05:49 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.
afair you told yourself that
var = <statement> where:
<suite>
translates to:
def unique_name():
<suite>
return <statement>
var = unique_name()
in this case class gets unique_name() function? is it that bad?
anyway I'd prefer to change semantics deeper. adding new statement-only
scope and adding our suite-definitions there.
More information about the Python-list
mailing list