lua-users home
lua-l archive

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


> If you need to do the above in a loop, make a Lua function which
> returns dummy closures (with unique _ENV upvalues) and cache that
> function:
> 
> luaL_loadstring(L, "local _ENV; return function() end");

Detail: if the function does not use _ENV, it will not have the
required unique upvalue:

  luaL_loadstring(L, "local _ENV; return function() return x end");

-- Roberto