lua-users home
lua-l archive

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

2010/5/20 Pierre-Yves Gérardy <>:
> On Thu, May 20, 2010 at 18:15, Roberto Ierusalimschy wrote:
>>  local a function foo () return a + b end
>> In function foo, the first upvalue is 'a' and the second is '_ENV'.
> Why isn't it always the first upvalue? It would make things easier if one
> wants to play with the environment...

If you change "a + b" to "b + a", the upvalues get reversed.  The
implementation appears to order upvalues in the order in which they
are used, not the order in which they are defined.