News for hackers. Stuff that matters.
Re:The new PHP by coldtea on Tuesday March 04, 2014 @02:33PM (#7342480)
Yeah, so? Sounds even better, as you can only declare what you'll actually use from the enclosing scope.

Besides, doesn't Python work the same way?

Re:The new PHP by anaphor on Tuesday March 04, 2014 @02:38PM (#7342514)
Wrong. You only need to use the free variables of the closure, you don't need to copy the entire environment from the function you're defining your closure in. By the definition of a free variable you actually use it, otherwise it wouldn't be a free variable of the function! Python definitely does not work the same way, but in Python "x = 3" can inadvertently shadow (make a local name) something defined in the outer scope, but that's a completely different problem.
Re:The new PHP by gdwatson on Tuesday March 04, 2014 @02:45PM (#7342553)
In modern versions of Python you can declare "nonlocal x", but that's only necessary if you want to assign to x. Since assignment in Python creates a local variable by default, there needs to be a way to tell the byte compiler not to shadow the nonlocal variable.

If you don't assign to x, the compiler will do the right thing without help.