lua-users home
lua-l archive

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


Not true, there is nothing to prevent you taking a copy of the light user data from the table. The point is that neither Lua nor C can know when the item is freed at the language level .. your application might have business rules that controls the lifecycle, which is fine (just like you have to manage pointers by hand in C).

--Tim


On Jun 9, 2013, at 8:26 AM, Kevin Martin <kev82@khn.org.uk> wrote:

> 
> On 9 Jun 2013, at 12:05, Tim Hill wrote:
> 
>> so it is of limited use unless the pointer is to static memory or heap memory that will not be released until after the Lua state is closed. I'm with you.
> 
> This isn't true if the light userdata are stored in a table which has a gc metamethod to call the appropriate free function.
> 
> I hardly ever use full userdata as an object, but instead use a table and put light userdata in it. I find it much more flexible than full userdata.
> 
> Kevin