lua-users home
lua-l archive

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

Some a long time ago Roberto make a joke about per-value metatable
here[1], in a feature request raised by cloud wu[2].

I found that's very exciting[3], but I missing the message that
Roberto says that is just a joke[4]. 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
this field?

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?


Xavier Wang.