lua-users home
lua-l archive

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


On Mon, Apr 8, 2013 at 9:30 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
>
> It is expected; tables-with-holes (those containing nils) are not guaranteed
> to work properly with #
>
> Different versions of Lua will in fact give different results, some of them
> 'correct'. This is undefined behaviour

In 5.1, it was defined but not deterministic.

In 5.2, the length "is only defined if the table is a sequence", but
it's not clear whether applying the length operator to such a table is
"undefined behavior" as that term is used in languages such as C.

For that matter, in 5.2 it doesn't seem to actually be defined that
the length of a table with no positive numeric keys is 0 (does the set
"{1..0}" have any more meaning than something like "{1..-1}"?). And it
seems the length of tables with positive numeric keys that are not
integers (e.g. { 'a', [1.5]='b', 'c' }) is not technically defined,
either.