lua-users home
lua-l archive

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

On Wed, Jun 6, 2018 at 10:34 PM, Egor Skriptunoff <> wrote:
I think Rodrigo is correct.
We don't really need NIL_IN_DICTIONARY, we only need NIL_IN_ARRAY.
And the "array border" (or "high water mark") is the right word to solve the problem.

The idiom I would like to see makes #tab a valid L-value.

Then we could say:

tab = {1,2,3, [50] = 50}

#tab = 50

and ipairs would yield 1,2 ; 2,2 ; 3,3; 50,50.

This would be more attractive than the =tab.n= idiom we find ourselves settling on. 

This new over-ride of #t should behave like the old #t, in that

tab[#tab + 1] = 51 -- #tab is now 51

tab[99] = 99 -- #tab is still 51
#tab = 99     -- and so on 

Add a verb to table to do this in one call:

table.extend(tab, 99, "99")  -- String is the rvalue

I don't get tripped up on sparse tables often, this would solve all the cases I've personally run into.