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

Nick Coghlan ncoghlan at iinet.net.au
Tue Jan 11 05:24:21 EST 2005


Andrey Tatarinov wrote:
> 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?

No, I wasn't thinking clearly and saw problems that weren't there.

However, you're right that the semantic definition should include unbinding the 
unique name after the statement finishes. E.g. for assignments:

   def unique_name():
       <suite>
       return <expr>
   <target> = unique_name()
   del unique_name

> anyway I'd prefer to change semantics deeper. adding new statement-only 
> scope and adding our suite-definitions there.

A new scope essentially *is* a nested function :)

My main purpose with the nested function equivalent is just to make the intended 
semantics clear - whether an implementation actually _does_ things that way is 
immaterial.

Cheers,
Nick.

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



More information about the Python-list mailing list