[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Strong tables in Lua 5.4
- From: pocomane <pocomane_7a@...>
- Date: Fri, 16 Mar 2018 13:03:00 +0100
On Fri, Mar 16, 2018 at 12:31 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 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
>
I really like it.
Just a variation to address the issues that Roberto stated in the udef thread:
- Only the empty table constructor `{}` make a "Normal" table
- All the other table constructors, e.g. '{..}' or '{a_func()}', etc,
generate strong tables by defaults.