lua-users home
lua-l archive

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


> 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?

Sure. They are resurrected as much as u1 is, because the __gc in u1
might access any of these values.

Note that this already was true in 5.1, but the documentation was
not very clear about that.

-- Roberto