lua-users home
lua-l archive

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


On Mon, Jun 27, 2016 at 10:29 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> Bingo! I'd say an `n` key with an integer value greater than or
>> equal to 0, but let's not nitpick. I also think this would have been
>> a viable alternative to the sequence concept we now have, because it
>> has some useful properties:
>>
>> *  [...]
>
> Something that seems to be missing in this discussion is constructors:
>
>    l = {1, 2, 3, 4, 5}
>    print(#l)          --> ?  (no 'l.n'...)
>
> -- Roberto
>

I think this has been mentioned before, but my personal opinion is
that table.pack is effectively the "array constructor".

l = table.pack(1, 2, 3, 4, 5)
print(#l)  --> 5, obviously
print(l.n) --> also 5

/s/ Adam