lua-users home
lua-l archive

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

> 2013/7/2 Thomas Jericke <>:
>>  the array stores its length 'n' explicitly
> Come back, Lua 5.0! All is forgiven!

Why do you think we're suggesting that?

That being said in 5.0 it wasn't a type in its
own right, just a few functions that assumed
things in the table library.

Here's what I would like to see:

    local a =
    type(a) -- "sequence"
    #a -- 0
    a[#a+1] = {}
    a[5] = 3
    #a -- 5
    a -- [1, {}, nil, nil, 3]
    a.stuff -- error
    a.n -- error (use #)

What a[0] and a[-1] would be should be discussed.
Personally, I would go with a[0] being *an error*
and a[-1] being 3.

We would also pass a table to the constructor to
convert it to an sequence (for backwards
compatibility and easier initialization):

    a ={1,5,9}

I don't really care about the name (I used sequence
in the example to avoid the real candidates:
vector, list, array...)

Pierre Chapuis