lua-users home
lua-l archive

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


Define a "strong table" as one in which 't[k]=nil' does not remove the
key, it stores nil.

In Lua 5.4 (work1), all or no tables are strong, depending on
LUA_NILINTABLE. A new keyword 'undef' is needed to remove a key from a
strong table.

If instead of that, a hitherto unused letter of the __mode metafield
(say 'n') is used to indicate whether a table is strong, then
(a) strong and non-strong tables could coexist in the same code;
(b) no compiler variable would be needed

To remove a key from a strong table, a function table.undef could be
supplied that temporarily replaces 'n' in __mode by a neutral letter
and does a rawset.