lua-users home
lua-l archive

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

On Tue, Apr 03, at 03:25 Oliver Kroth wrote:
> Am 03.04.2018 um 15:02 schrieb Ahmed Charles:
> > Written before I was born, EWD831
> > (
> > describes why 0 based ranges are superior better than I can. It has
> > nothing to do with programming languages and everything to do with math.
> Actually, Dijkstra just prefers to have items counted like 0,...,N-1 instead
> of 1,...,N
> odd.
> When I count things, let's say, cows, I start with the first cow and say
> "one", second cow "two",  third cow counted "three"...
> I would not start with the first cow and say "zero", I say "zero" when there
> is no cow at all.
> A zero-th cow is the cow in the empty corral, and actually "not a cow"...

I'm going to be another one that bites the dust here.

So, lets say that we could talk with a just born human child, and asked him:
  how old are you?

Is not one, but is not zero either. He actually is zero and an offset.
Back in the old times learned to say that we are __at__ [age] or walking
at [age].

In this regard and in a humanish way of thinking and without second
thoughts, Lua got it right. But i do not think that machines thinks the

And more philosophically:

What could be the one without the zero? It has no meaning, as it requires a
starting point to exist and calculate itself and the next same objects, even
if it is a cow or a goat (its wise that you've used cows and not goats in the
example (but this is another story)).

But now, what do you think that would be the kid's answer after one year?

For the record and in mho, C like languages choosed very wiselly to refer at
the starting point of the object address (or n-1) and for a good reason.

Technically speaking (probably) is this expression:

   0  -> sizeof (obj)  1

and not this
   0  sizeof (obj) <-  1

But also is not wrong for Lua but it has to deal somehow in cases, where
zero is natural.

(but see that both sides are talking about the same thing here (it is one
element after all) and specifically the first one))

> I would not start with the first cow and say "zero", I say "zero" when there
> is no cow at all.

Anyway and since we are going to live in the kingdom of Rust, and because Rust as
C uses zero for its first element, i believe we have a winner here, even if they
did bite the dust.