lua-users home
lua-l archive

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


On Thu, Dec 1, 2011 at 7:18 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> Thanks for updating [1] the documentation with respect to resurrected
>> objects. Can we interpret:
>>
>> "Because the object being collected must still be used by the
>> finalizer, it (and other objects accessible only through it) must be
>> resurrected by Lua."
>>
>> to include a userdata's user value and all values the user value references?
>>
>> [1] http://lua-users.org/lists/lua-l/2011-09/msg00086.html
>
> I am afraid I did not understand your question (im particular, its
> relationship with [1]).

So if we have two new userdata in global variables u1 and u2:

setmetatable(u1, {__gc = function() end)
-- u2 does not have a __gc metamethod
uservalue = {link = u2}
debug.setuservalue(u1, uservalue)
u1, u2, uservalue = nil, nil, nil
collectgarbage "collect"

My question is: can we expect uservalue (the table) and u2 to be
"resurrected" temporarily?

-- 
- Patrick Donnelly