[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What is 'light' user data?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 23 Sep 2013 16:55:44 -0300
> 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.