Greg Ewing wrote:
> Jim Jewett wrote:
>
>> Knowing which i's to rename strikes *me* as tricky,
>
> It shouldn't be too hard if you approach it the
> right way. One way would be to temporarily change
> the symbol table entry for the loop var when
> compiling the loop body and any nested functions
> so that it refers to a different slot in the
> locals.
The more I think about it, the more I think it will be simplest to tackle the
list comprehension as a 'pseudo-scope'. These would still effectively create
new scopes, but because they're executed immediately, they can get away with
borrowing the local namespace and execution frame of the current function
rather than running independently.
The compiler already has to keep track of which scope it is in order to handle
closure variables - the idea would be to add a mechanism to the scope stack
whereby each entry could either be a 'real' scope (actual separate local
namespace) or a 'virtual' scope (names in the scope are remapped to start with
an appropriate numeric prefix in the current local namespace).
Georg, if you want to tackle this, go ahead. Otherwise, I'll look into it over
the next couple of weeks.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com