lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> 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.

-- Roberto