[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Feature request: per-value uservalue
- From: Xavier Wang <weasley.wx@...>
- Date: Mon, 20 Mar 2017 03:03:32 +0800
Some a long time ago Roberto make a joke about per-value metatable
here, in a feature request raised by cloud wu.
I found that's very exciting, but I missing the message that
Roberto says that is just a joke. So sad, because this won't in Lua
because it can not support __gc meta-method.
__gc method may called when last value in Lua disappeared, if a
metatable attach to value, it's no way to know how to free the gc
objects. So metatable can not attach with value together.
but, for now only full user data has the user value, setting/getting
it using Lua API: lua_getuservalue()/lua_setuservalue(). So can we use
the extra bits in value and make every value has uservalue? a integer
is enough because we could put real value into a ref table. or make a
internal array for the uservalue? When a value disappear we could just
free the slot that this value use? or any ways to put a pointer in
I just very want this feature in future Lua, I think the per-value
metatable will in next Lua by mistake. So could anyone interesting
about this and re-discuss it in formal?