[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tables
- From: "Adam D. Moss" <adam@...>
- Date: Mon, 06 Mar 2006 00:18:00 +0000
Chris wrote:
Can someone define what a "hole" in an array is?
nil(s) in an otherwise contiguous run 1..n
> Why can't I have an array with nil values in it?
you can, but the table length operator on such an array
is defined as in the manual.
> But again, judging by the actual
behaviour, setting a particular entry in an array to nil is not
considered a hole.
No, it's a hole. It simply may or may not affect the length
operator, as documented, resulting in a length that you may or
may not expect.
However, if a change in implementation could change this behaviour that
makes me feel uneasy.
The length operator works as documented, and presumably a change
in implementation would also work as documented. You should ask
yourself what the expected behaviour would be given an array
with holes (count up to the first nil? count up to the last
non-nil? something else?). For efficiency Lua's length operator
only gives a unambiguous answer in the absence of holes, and
is possibly over-wordily documented as such; if you utterly
require a specific policy in the presence of holes you can
implement it easily enough.
> This whole issue makes me realize that Lua really
needs an official well defined language specification to be taken seriously.
I take Lua pretty seriously!
--adam
- References:
- tables, D Burgess
- Re: tables, Chris
- Re: tables, Chris
- Re: tables, D Burgess
- RE: tables, Dolan, Ryanne Thomas (UMR-Student)
- Re: tables, D Burgess
- RE: tables, Dolan, Ryanne Thomas (UMR-Student)
- Re: tables, Chris