lua-users home
lua-l archive

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

Tim Hill <>于2017年3月20日周一 上午11:12写道:
Other than tables or full userdata (which have per-value metatables), what do you need? I’m unclear on what use a metatable on a particular string, or a light userdata would have (why would it not be a full userdata in that case?).

lightuserdata can be a sub struct of an complex C/C++ object .

For example, in 3d engine, a node of a 3d object as a lightuserdata would be better than full userdata. If you query a node of a 3d object from lua , you can create a full userdata proxy for it, but you should also cache it in uservalue because it should be the same value in next query ( __eq is not enough if you want to use it as a table key).

Using lightuserdata (with metatable) for a 3d node would simplify the bindings of 3d engine and reduce the overhead.