Light User Data |
|
* Light userdata have the semantics of values, while heavy userdata have the semantics of objects. Objects have a unique identity [1]: Two heavy userdata constructed with the same data will always be distinguishable (e.g. rawequal will differentiate them by memory address); two light userdata such constructed will never be distinguishable because they are compared by value not by address. |
* Light userdata have the semantics of values, while heavy userdata have the semantics of objects. Objects have a unique identity [1]: Two heavy userdata constructed with the same data will always be distinguishable (e.g. rawequal will differentiate them by memory address); two light userdata so constructed will never be distinguishable because they are compared by value not by address. |
type(x) == 'userdata', but these two forms of userdata are otherwise quite different in behavior [1], as outlined below.
rawequal will differentiate them by memory address); two light userdata so constructed will never be distinguishable because they are compared by value not by address.
x is a lightuserdatum, then x == y if-and-only-if y is a light userdatum representing the same pointer. Light userdata can be used as table keys, in which case x == y implies t[x] and t[y] refer to the same table value (though not necessarily that t[x] == t[y] since NaN ~= NaN). The __eq metamethod has no effect on light userdata (note: the manual isn't clear on this [1]).
nil).
tostring(x) typically displays the pointer in hex notation, although this is specific to LuaImplementations.
Some interesting points: