[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (alpha) now available
- From: steve donovan <steve.j.donovan@...>
- Date: Sun, 12 Dec 2010 15:05:40 +0200
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.
As it has been discussed, probably ad nauseum, don't put holes in
arrays _intentionally_. But it's easy to do it unintentionally. The
paranoid programmer will do things like table.insert(t,assert(val)) to
catch these things early, or use special 'null' sentinel values. One
idea might be a special table mode that provides some kind of
protection (wrap or throw an assertion)
steve d.