lua-users home
lua-l archive

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


On Wednesday, July 24, 2013 01:08:30 PM Leo Romanoff wrote:
> - Yet another issue, where I'm not sure about what's possible already
> today, is the ability to refer to Lua objects from userdata objects. Is it
> possible today? I.e. can I create a userdata C-array which refers to Lua
> objects directly? IMHO, it is not the case today, because it would
> introduce problems with current GC implementations as they are not able to
> trace inside userdata objects. But I think that being able to refer to Lua
> objects from userdata could be very useful for an efficient implementation
> of many data structures.

lua_setuservalue and lua_getuservalue do this. It associates a table with a 
userdata. The UD then can store any values it needs in its private table. In a 
past life, this was done with lua_setfenv.

-- 
tom <telliamed@whoopdedo.org>