lua-users home
lua-l archive

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


Of course! Thanks!
 

> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br 
> [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Aaron Brown
> Sent: Monday, July 23, 2007 3:01 PM
> To: Lua list
> Subject: Re: Can't list all the non-local values with debug.getupvalue
> 
> 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
> (http://www.lua.org/manual/5.1/manual.html#2.6):
> 
> # 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
> 
>   TESTUP1, TESTUP2 = TESTUP1, TESTUP2
> 
> --
> Aaron
> http://arundelo.com/
> 
>