[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 (work1) now available
 
- From: Hisham <h@...>
 
- Date: Wed, 14 Mar 2018 09:30:50 -0300
 
On 14 March 2018 at 09:04, Coda Highland <chighland@gmail.com> wrote:
> On Wed, Mar 14, 2018 at 1:04 AM, Russell Haley <russ.haley@gmail.com> wrote:
>>> u = table.move(t,1,#t,1,{})
>>> for i,v in pairs(u) do print(i,v) end
>> 1       one
>> 2       two
>> 3       four
>> 4       nil
>> 5       five
>>> #t
>> 5
>>> t[4] = undef
>>> for i,v in pairs(t) do print(i,v) end
>> 1       one
>> 2       two
>> 3       four
>> 5       five
>>> #t
>> 3  --<<<<<< I Expected 4 here?
>>>
>
> This is expected. You have a table with a hole in it -- and you
> explicitly constructed it that way. The length of the sequence part of
> t is, in fact, 3.
But if I follow correctly, "#t" wasn't changed to mean "the length of
the sequence part" (i.e. highest integer n for which [1, n] are all
existing keys). See:
> #t
4
> t[3] = undef
> for i,v in pairs(t) do
>> print(i,v)
>> end
1       one
2       two
4       four
> #t
4
In the presence of holes, #t seems to still have the same
easy-to-define/hard-to-understand semantics from Lua 5.1-5.3. (Note I
haven't checked the sources or played with this at all — this is just
guessing from Russell's examples.)
-- Hisham
- References:
- [ANN] Lua 5.4.0 (work1) now available, Luiz Henrique de Figueiredo
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Luiz Henrique de Figueiredo
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Xavier Wang
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Roberto Ierusalimschy
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Tomás Guisasola
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Coda Highland
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Russell Haley
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Coda Highland
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Russell Haley
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Russell Haley
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Russell Haley
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Russell Haley
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Russell Haley
 
- Re: [ANN] Lua 5.4.0 (work1) now available, Coda Highland