lua-users home
lua-l archive

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


On Dec 14, 2007 3:34 PM, Eike Decker <eike@cube3d.de> wrote:
> The userdata needs only to overload the __newindex and __index metatable and
> store new key/values in a table inside the metatable of the userdata OR (if the
> userdata shouldn't have unique metatables) store the value in a table of the
> registry where the key values are the userdata values and it's a __mode='k'
> table, so it's weak.

There is another solution for this - userdata also has an environment
table, which is not internally used for anything, so you can easily
associate an arbitrary table to each instance of a userdata using
lua_setfenv and lua_getfenv while sharing a single metatable.