[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Making Lua lexically scoped (was: Re: Proper tail recursion)
- From: "Nick Trout" <nick@...>
- Date: Fri, 27 Jul 2001 17:28:47 +0100
----- Original Message -----
From: "John D. Ramsdell" <ramsdell@linus.mitre.org>|
| Correct. Statements inside the function bound to foo in the do block
| cannot access its local variable a. If it could, a function bound to
| foo could be written that accesses the value of a and then prints it,
| in this example displaying "10". In Lua, the current binding of a
| local variable is hidden from any function defined within the scope of
| the local variable. This is a problem only if the binding is changed
| between the time at which the closure for the function is created, and
| the time at which the function is executed.
So Lua is not lexically scoped because a) Upvalues only go up one level and b)
upvalues force a closure?
Does that mean that Python (2.2) is not lexically scoped either because it also
forces a closure? (but can look right to the outer level)
http://python.sourceforge.net/peps/pep-0227.html
So in order for a language to be truly lexically scoped rebinding must take
place on an assignment?
I have quite a limited knowledge of the practicalities but lexical scoping (and
the removal of upvalues) of the type employed in Python would be nice. ie.
closure at execution time.
Puzzled,
Nick