lua-users home
lua-l archive

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

On Aug 19, 2016, at 10:13 AM, Viacheslav Usov <> wrote:

On Fri, Aug 19, 2016 at 6:08 PM, Viacheslav Usov <> wrote:

> Such use, as the very next sentence in my message explained, makes them dictionaries, not arrays.

This distinction is made in Lua's manual, too.

Unless a __len metamethod is given, the length of a table t is only defined if the table is a sequence, that is, the set of its positive numeric keys is equal to{1..n} for some non-negative integer n. In that case, n is its length. 


Either a table is a sequence or it is not; it cannot be both at the same time. The term "array" is used officially either in "associative array", or in the part that specifies the C language API, so it was not correct to the term "array" in this discussion at all, but I'm not the only one guilty of that. I think it is safe to say that where we said "array" earlier, we meant "sequence”.

Incorrect. The definition defines if a table is ALSO a sequence. It does say it must ONLY be a sequence. The definition discusses the meaning of “positive numeric keys” and the language makes it clear that use of other keys are orthogonal to the definition of a sequence.