[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.2 sequence definition - clarification needed
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Wed, 29 Jun 2011 18:02:07 +0200
On 29/06/2011 17.27, James Graves wrote:
I would re-write that section as follows:
Unless the __len metamethod is set, the length N is defined for a
table which contains consecutive, positive integer keys from 1 to N
and does not contain any positive integer keys outside the range 1 to
N. Such a table is said to contain a 'proper sequence'.
The following types of keys do not affect the length of the table and
whether or not it contains a proper sequence:
negative integer (-1, -2, -55, etc.)
non-integer (-1.3, 3.14159265, etc.)
Really? I don't know the internals of Lua, but I thought positive
numbers, even non-integer ones, could make the table a non-sequence.
From the current definition it seems so, anyway. I.e.: a table is a
sequence if its positive numeric keys (non necessarily the integer ones)
*are* 1,2...,n (not *contains*).
I find the current definition much clearer IMHO (save for the glitches I
mentioned in the other post)
other non-numeric (strings, tables, functions, etc.)