lua-users home
lua-l archive

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


On Wed, May 21, 2014 at 8:53 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
> Am 22.05.2014 04:57 schröbte Coda Highland:
>> At this point, my personal recommendation would be to use tables
>> containing a lightuserdata, and maintain a C-side refcount independent
>> of the Lua refcount.
>
> This sounds like manual resource management to me, but I can't imagine a
> situation where lightuserdata would solve an object lifetime problem anyway,
> so I might be missing something here.

It's more that full userdata becomes pointless if you're not using it
to manage the object lifetime anymore, so switching to lightuserdata
lets you do equality comparisons on return values from C, including
mapping the lightuserdata back to the Lua object; you can't do this
with full userdata without attaching another key to it.

/s/ Adam