lua-users home
lua-l archive

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


> Because *people* count from one, not zero.  
> 
> We do that in kindergarten, in music, when starting a race, when drawing
> up an agenda, everywhere.  One, two,three, etc have their counterparts in 
> every known language on earth.
> 
> Zero, on the other hand, is an advanced concept.  Humanity could prove 
> that sqrt(2) is not a rational number centuries before anybody thought 
> that a symbol for zero might be useful.
> 
> A harder question would be "why do arrays in some other languages count 
> from zero not one?"  The answer for C is a good one: "so that *(A+k) and 
> A[k] mean the same".  For Python, the answer seems to be "because it's 
> that way in C".

I am going to discuss a little about 0-based x 1-based in my talk at the
Lua workshop, and my slides have exactly these arguments!!

| Currently, many languages are 0-based due to influence from C.
|   Ironically, none of them share the reason that made C 0-based
|   (where a[e] means *(a+e)).

(I also added: "However, several other languages are 0-based without
that influence. Examples include Scheme, Oberon, and Haskell.")

-- Roberto