[DGD]Casting to int

abigail at delanet.com abigail at delanet.com
Fri Jun 30 19:12:46 CEST 2000


On Fri, Jun 30, 2000 at 03:07:33PM +0200, Mikael Lind wrote:
> 
> I agree that array indices should start at 1. 0 has a low-level
> computer connection; the array index as an offset from the first
> element. 1 is more suited for mathematic and scientific connections,
> as well as human expressions - the first element is element number
> one.

Actually, mathematicians start counting from 0 at least as often as 1.

> With new computer languages moving farther away from their
> computer-friendly ancestors and more towards human-friendly aspects,
> I think that 1 is better suited as the first index; certainly in a
> language like LPC.

So, FORTRAN was way ahead of its time? ;-)

I'd say that if you want to make a more human-friendly language, the
chance isn't that you start indexing from 1, but that you leave it to
the programmer to decide. Pascal gives the programmer the choice on an
array by array basis. Perl also gives the programmer a choice, but in
such a butt-ugly way that it's marked "DO NOT DO THIS". (My point? The
concept of indexing starting elsewhere then 0 has been tried, and with
mixed results.)

Personally, I prefer the Pascal approach. Both 0-based and 1-based
indexing are convenient at times, and inconvenient at other times. If
one could pick the base on a case by case basis, one could pick the best
of two worlds (at the sacrifice of uniformity though).


Abigail

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list