lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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
>
>