[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Speed of #t
- From: David Kastrup <dak@...>
- Date: Mon, 13 Dec 2010 13:10:25 +0100
Enrico Colombini <erix@erix.it> writes:
> On 13/12/2010 11.14, Axel Kittenberger wrote:
>> Likely I'm a bit naive about this. But couldn't we just define for #
>> operator to simply return the size of the array part?
>>
>> Meaning counted from 1 onwards # to defined the the largest numeric
>> key where t[k] is not nil. t[#t+1] is nil.
>
> I'd be happy with that, but (apart from other people having different
> wishes) consider what will happen if you have a table such as:
>
> t = { 1, 2, 3, nil, 5, 6, 7, ... } -- a very very large table
>
> #t would be 3.
> Now fill the hole:
>
> t[4] = 4
>
> To update #t correctly according to your definition, all the remaining
> length of the array would probably have to be traversed sequentially.
Why? t[4] = 4 will presumably just increase the array part by one,
resulting in #t == 4.
--
David Kastrup
- References:
- Re: [ANN] Lua 5.2.0 (alpha) now available, Richard Hundt
- Re: [ANN] Lua 5.2.0 (alpha) now available, Dirk Laurie
- Re: [ANN] Lua 5.2.0 (alpha) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.2.0 (alpha) now available, Enrico Colombini
- Re: [ANN] Lua 5.2.0 (alpha) now available, steve donovan
- Re: [ANN] Lua 5.2.0 (alpha) now available, Geoff Leyland
- Re: [ANN] Lua 5.2.0 (alpha) now available, Enrico Colombini
- Re: [ANN] Lua 5.2.0 (alpha) now available, Peter Cawley
- Re: [ANN] Lua 5.2.0 (alpha) now available, Dirk Laurie
- Re: [ANN] Lua 5.2.0 (alpha) now available, Enrico Colombini
- Speed of #t (was: Re: [ANN] Lua 5.2.0 (alpha) now available, Dirk Laurie
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, Axel Kittenberger
- Re: Speed of #t, Enrico Colombini