lua-users home
lua-l archive

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


> In lua 5.2, my understanding is that _ENV is always the first upvalue. Is
> this not true?

It is true for main chunks but not for individual functions.

Consider the program below and run luac -l -l -p on it:

   local x
   function f() return x+y end
   function g() return x end
 
Then _ENV is the first (and only) upvalue of the main function,
but it is the second of f and is not an upvalue of g.