lua-users home
lua-l archive

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


On Fri, Aug 21, 2015 at 12:55:46AM +0200, Philipp Janda wrote:
> Am 21.08.2015 um 00:21 schröbte Rena:
> >On Aug 20, 2015 6:05 PM, "Roberto Ierusalimschy" <roberto@inf.puc-rio.br>
> >wrote:
> >>if we want to put some extra bits in
> >>'TValue' to good use and solve the OP problem, maybe a better idea would
> >>be to introduce metatables for light userdata.
> >
> >That would be excellent. I find it difficult to find much real use for
> >light userdata with only a single global metatable.
> 
> That would be another welcome feature, but lightuserdata pointing into full
> userdata is unsafe: the full userdata could be collected without the
> lightuserdata realizing/preventing that.

You wouldn't do that. You would store the reference to the full userdata in
the metatable, not as the lightuserdata value. The lightuserdata would only
contain the offset. That would require only one unique metatable per full
userdata, not per lightuserdata proxy.