lua-users home
lua-l archive

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


On Sun, Jun 21, 2009 at 7:38 PM, bb<bblochl@arcor.de> wrote:
> Is`nt it possible to tackle that problem in the new version?

First you need to see it as a problem, which I for one do not. The
length operator for tables (IMO) returns the length of an array, where
an array is a table whose integers keys are continuous from 1 to N. An
array with holes in it is thus not an array, as its integer keys are
non-continuous, and hence the length operator is less well defined.
For non-arrays, the length operator plus one gives a free integer key.

If you were to "fix" this "problem", how would you define the length
operator for tables?
1) Total number of keys in the table?
2) Total number of integer keys in the table?
3) Biggest integer key in the table? (and for tables with no integer keys?)
4) Smallest integer key in the table which is followed by a nil? (and
for tables with no integer keys?)
5) Something else?