lua-users home
lua-l archive

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


> AFAIC, there are three use cases for lightuserdata:
> 
> [...]

There is another important use case (actually the one that motivated the
inclusion of light userdata in the language): If you want to associate
a Lua object with a generic C object, you can store the Lua object in a
table using the C-object address as the key into that table. (Lua code
sees neither the table nor the keys.)

You could use reference for that, but then you must be able to insert
an extra field into the C object, something that can be impossible if
that object comes from someone else's library.

-- Roberto