"Paul Rubin" <http://[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> It's not obvious to me how the compiler can tell.  Consider:
>
>    x = 3
>    if frob():
>       frobbed = True
>       squares = [x*x for x in range(9)]
>    if blob():
>       z = x
>
> Should the compiler issue a warning saying the program should be taken
> out and shot?  With lexical comprehensions, the program is perfectly
> valid and sets z to 3 if blob() is true.  The whole point of lexical
> comprhensions is to make Python safe for such programs.
>
> Without lexical comprehensions, the program still doesn't depend on
> the listcomp leakage if frob() and blob() aren't simultaneously true
> (envision "assert not frobbed" before the "z = x").  So "should be
> taken out and shot" is maybe a little bit extreme.

Actually, I don't think so.  If you intend for it to be impossible for "z = 
x" to refer to the x in the list comprehension, you shouldn't mind putting 
in "from __future__ import lexical_comprehensions."  If you don't intend for 
it to be impossible, then the program *should* be taken out and shot.


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to