[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Do Lua tables have an "array" and a "hash" part?
- From: Hisham <h@...>
- Date: Mon, 25 Jul 2016 23:19:26 -0300
On 23 July 2016 at 14:27, Coda Highland <chighland@gmail.com> wrote:
> On Sat, Jul 23, 2016 at 10:09 AM, Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br> wrote:
>>> Many people on this list say tables have an "array" and a "hash" part.
>>
>> That is an implementation detail. Even if the table is a sequence, it may
>> happen that part of it is in the hash part.
>
> I think that's the entire point.
>
> The comment seems to be that regardless of those implementation
> details, conceptually speaking tables DO have a "sequence" part (the
> set of integral-valued keys starting at 1 and going up until a nil is
> found or until the __len metamethod says to stop)
At the risk of being nitpicky, that's not how the manual defines
sequence. A __len metamethod does not define a sequence (in other
words, things with "holes" are not sequences):
>From Section 2.1 of http://www.lua.org/manual/5.3/manual.html
"We use the term sequence to denote a table where the set of all
positive numeric keys is equal to {1..n} for some non-negative integer
n, which is called the length of the sequence"
-- Hisham, just trying to constrain the concept space