lua-users home
lua-l archive

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


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