[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Speed of #t
- From: Axel Kittenberger <axkibe@...>
- Date: Mon, 13 Dec 2010 15:07:32 +0100
To be defined # as the lowest positive integer for which t[#]~=nil and
t[#+1]=nil instead of any would IMHO be preferable and more
intuatively from user perspective. (that is the last nonnil number
counter from 1 onwards), and it wouldnt break current lua code, since
lowest is just more exact than any. But I guess the difficulty is in
implementing it efficiently, and thats why we have the current any #
rule.
Furthermore I wonder for what the current implementation of # makes
any sense for an application except for strictly linear arrays, other
than the t[#t +1]=v case which can perfectly be covered already with
table.insert(t, v). Dunno why this take a few machine instructions
more (maybe because of looking up table in _G and then insert?), but
whatever, it might be worth it anyway.
Kind regards,
Axel
On Mon, Dec 13, 2010 at 2:56 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> The more I think about the alternatives for #t, the more I like the
>> current choice :-)
>
> It is more or less like democracy ;)
>
> -- Roberto
>
>
- References:
- 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
- Re: Speed of #t, David Kastrup
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, David Kastrup
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, Roberto Ierusalimschy