[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Redefining locals
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 11 Nov 2004 14:30:50 -0200
> Hehe, you have that exactly 180 degrees back to front about
> lexical scoping. :-) [...]
Lua implements lexical scoping, not dynamic scoping.
> Incidentally, that's why closures are called closures, ie. because
> they capture their environment at the moment the closure is formed.
> If the environment is kept open, it's not closed. The foo in your
> function is still a free variable! :-)
They capture the variables, not their values. The foo in that function
is not free at all, it is forever binded to the local variable created
with the first "local" declaration.