8.1 – Changes in the Language
The concept of environment changed. Only Lua functions have environments. To set the environment of a Lua function, use the variable
_ENV
or the functionload
.C functions no longer have environments. Use an upvalue with a shared table if you need to keep shared state among several C functions. (You may use
luaL_setfuncs
to open a C library with all functions sharing a common upvalue.)To manipulate the “environment” of a userdata (which is now called user value), use the new functions
lua_getuservalue
andlua_setuservalue
.Lua identifiers cannot use locale-dependent letters.
- Doing a step or a full collection in the garbage collector does not restart the collector if it has been stopped.
- Weak tables with weak keys now perform like ephemeron tables.
- The event tail return in debug hooks was removed. Instead, tail calls generate a special new event, tail call, so that the debugger can know that there will not be a corresponding return event.
- Equality between function values has changed. Now, a function definition may not create a new value; it may reuse some previous value if there is no observable difference to the new function.