lua-users home
lua-l archive

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


>Ha, I though I was starting to understand how closures, upvalues and
>variable scope was working on Lua, and I stumble upon a puzzling problem.

When in doubt of what a program does, try luac -l (or weblua).

>Obiviously, when I declare the List function, it takes a snapshot of the
>global values used inside it and uses them instead of the current value.

This is not true. The value of a global variable is always the current one
at the time it is used.

>1) I though it was only true for local values;

It was true with upvalues. But with full scoping in Lua 5.0, this is no longer
the case: there is no automatic freezing of values (you can simulate it though
by copying the value to a new local value that you don't modify).
--lhf