lua-users home
lua-l archive

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


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)