In Lua 5.1 all userdata have tables as environments. If you don't set an environment explicitly, one is inherited by the function that created the userdata (this is the global table _G
for newproxy
and the package
table for userdata created in C modules loaded via require
). Also, you can only replace the environment of a userdata with another table. In Lua 5.2 and 5.3 on the other hand, userdata start with nil
as the initial uservalue. You can set the uservalue to a table and back to nil
(Lua 5.3 also allows other values).
To emulate the behavior of Lua 5.3 the compatibility implementation of debug.getuservalue
for Lua 5.1 returns nil
whenever the userdata has an environment equal to _G
or the package
table, and the actual environment table otherwise.
You cannot use values other than tables (or nil
) in Lua 5.1 or Lua 5.2.
See also debug.setuservalue
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4