[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __gc is ignored for tables, isn't it?
- From: roberto@... (Roberto Ierusalimschy)
- Date: Thu, 8 Mar 2007 16:56:24 -0300
> If U is both a key and value then it follows the weak-key rule,
> finalize then remove table pair?
>
> t = setmetatable({},{__mode='kv'})
> U = ... some userdata with a __gc
> t[U] = U
> U=nil
> collectgarbage()
> -- U will be in t until after __gc is called?
The key follows the key rule, the value follows the value rule. Like
with any pair, if any of them is removed, the entire pair is
removed. So, in your example, that entry would be removed. (That is,
the U in t[U] is not being collected yet, but the U in "= U" is, so
the pair is removed.)
-- Roberto
- References:
- __gc is ignored for tables, isn't it?, Sam Roberts
- Re: __gc is ignored for tables, isn't it?, Roberto Ierusalimschy
- Re: __gc is ignored for tables, isn't it?, Sam Roberts
- Re: __gc is ignored for tables, isn't it?, Roberto Ierusalimschy
- Re: __gc is ignored for tables, isn't it?, Sam Roberts