lua-users home
lua-l archive

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


-1 on this. One of the advantages (for me) of userdata in Lua is that there is *no* language defined way that userdata can be modified. This means a C library can use Lua as the container for opaque data and be assured that whatever it stores there is not meddled with. If you want this sort of functionality on some specific userdata, then it’s pretty easy to expose an appropriate custom API for that purpose.


But we use full userdata rather than light userdata because full userdata is a gc object.

In  many cases, we need reference the different parts of an object, but they are the same one object (to garbage collector). If we create dozens of userdata for them,  we need more expensive works : cache these reference userdata in a weak table, put the root object in their uservalue, etc.