[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua next version
- From: bb <bblochl@...>
- Date: Sun, 21 Jun 2009 22:21:46 +0200
Am Sonntag, den 21.06.2009, 19:52 +0100 schrieb Peter Cawley:
> 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?
Well, I see that any restriction in any way is contrary to that
absolutely open structure Lua tables are to be. Obviously no one else
sees that as a real problem. May be that my thinking is to much
constricted by all the other languages I had and have to deal with. It
is a bit hard to explain to users of other languages, that there is no
fixed length by declaration and one can set a new element on any
position without any check etc. ...
I found that the Lua Matrix package and some bindings to well known math
packages, numlua and others maybe will release me from handling matrix
elements in Lua myself.
Regards BB