lua-users home
lua-l archive

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


This part of section 3.4.7 (The Length Operator) is very vague on what
should happen when 'border' is the maximum integer:
"
The length operator applied on a table returns a border in that table.
A border in a table t is any natural number that satisfies the
following condition:

     (border == 0 or t[border] ~= nil) and t[border + 1] == nil

In words, a border is any (natural) index present in the table that is
followed by an absent index (or zero, when index 1 is absent).
"
If the length operator is used on a table that has all positive
integer indices and the minimum integer index set to a non-nil value,
what should happen?
There is no natural number which satisfies the condition provided.
Because the addition operator will wrap around, the maximum integer
will not satisfy the condition as the minimum integer index has a
non-nil value.
>From looking at the Lua 5.4.3 source I think Lua currently returns the
maximum integer and ignores the minimum integer index.