[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (alpha) now available
- From: Geoff Leyland <geoff_leyland@...>
- Date: Mon, 13 Dec 2010 07:57:39 +1300
On 13/12/2010, at 2:05 AM, steve donovan wrote:
> On Sun, Dec 12, 2010 at 2:03 PM, Enrico Colombini <erix@erix.it> wrote:
>> A minimalist crazy idea: perhaps, just to avoid surprises and offer a
>> predictable behavior to Lua beginners, #t could return nil if the list has
>> holes (i.e. it's not a proper array).
>
> But that would break a lot of existing code that assumes that #t is
> always safe - I find myself using #t > 0 to tell if something is a
> array.
t[1] is quicker than #t > 0, especially if t is a long array. (Not my idea, Javier Guerra pointed this out in http://lua-users.org/lists/lua-l/2008-03/msg00540.html)