lua-users home
lua-l archive

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


> [...] (Is there a way to avoid that first upvalue?) [...]

Yes:

  Any access to lua_upvalueindex(n), where n is greater than the number
  of upvalues of the current function (but not greater than 256, which
  is one plus the maximum number of upvalues in a closure), produces an
  acceptable but invalid index.

  https://www.lua.org/manual/5.3/manual.html#4.4

Plus:

  For functions that can be called with acceptable indices, any
  non-valid index is treated as if it contains a value of a virtual type
  LUA_TNONE, [...]

  https://www.lua.org/manual/5.3/manual.html#4.3

-- Roberto