lua-users home
lua-l archive

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

Tim Hunter wrote:

The program works the way I expect it to, except that it
does not list the values of TESTUP1 and TESTUP2.

This is because the function test doesn't "close over"
TESTUP1 and TESTUP2.  For a variable to be an upvalue to a
function, it has to be used somewhere in that function

# A local variable used by an inner function is called an
# upvalue, or external local variable, inside the inner
# function.

Your test program will print the names and values of TESTUP1
and TESTUP2 if, for instance, the test function includes
something like