[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Applying the # operator on a table
- From: Brad Jorsch <bjorsch@...>
- Date: Mon, 8 Apr 2013 12:08:01 -0400
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.