lua-users home
lua-l archive

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


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.

Btw., on 64 bit machines we have another 32 bits available due to padding (TValue is already 16 bytes there). It's only 32 bit machines where we'd have to deal with 24 bits or so.


(We could even gain individual metatables for numbers :-)

So different metatable for 4 than for 5? That would be... interesting.


Since the metatable "pointer" would be stored in the TValue itself you could even have multiple numbers with value 4 on the stack and assign a different metatable to each.

Philipp