[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 10:08:58 -0300
> > > Do I have this right?
> >
> > Almost. Light userdata are values, too.
>
> Ouch, thank you!
>
> On closer reading, it is in the refman, 2.2:
>
> [...]
>
> I'm sure there is no end to stuff that could be jammed into the ref man,
> [...]
If you want the gory details, there is another relevant stuff in the
interaction between weak tables and userdata that is missing from the
manual. Assume a userdata U that has a finalizer (a __gc metamethod).
If U appears as a value in a weak(value) table, it is removed before
the calling of its finalizer. But if U appears as a key in a weak(key)
table, it will be removed only after the calling of its finalizer.
(This allows the finalizer to access properties related to the userdata
via a weak table.)
-- Roberto