On 12/20/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 12/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 12/20/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > > > I haven't actually tried to implement that, though, and I suspect things > > > will > > > get a little tricky when it comes to dealing with nested scopes like > > > '[(lambda > > > i=i: i) for i in range(10)]'. > > > That doesn't strike me as tricky; I expect it'll happen automatically > > if you do the right thing. > > [(lambda i=i: i) for i in range(10)] > => > [(lambda i=0_i: i) for 0_i in range(10)] > > The argument to lambda can't be renamed, because it could be called as > a keyword.
Well duh, the renaming must observe the scope of the variable. Butthat's no big deal since we observe the scope when generating code for it anyway (references to locals need to use different bytecode than globals, and references to variables from outer nested scopes need to use cell references). Perhaps you were thinking of a textual substitution? That's not at all how one would do this. > Knowing which i's to rename strikes *me* as tricky, to the point where > I would suggest at least considering a "works as implemented" > pronouncement. This (along with further nesting, closure variables, > conditionally defined variables, etc) is obscure enough that backwards > incompatibility could be justified, if it made the explanation (or > implementation) simpler. I have no idea what you mean by "works as implemented". Do you propose *not* to fix the scope bleed of list comprehension loop control variables? That's not an option. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ 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
