Array start index

DLearner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 1 02:35:51 PDT 2015


Does the D language set in stone that the first element of an 
array _has_ to be index zero?
Wouldn't starting array elements at one avoid the common 
'off-by-one' logic error, it does
seem more natural to begin a count at 1.

Actually, maybe even better to allow array definitions of form
int foo[x:y];
(y >= x) creating integer variables foo[x], foo[x+1],...,foo[y].

I think the (very old) IBM PL/I language was like this.


More information about the Digitalmars-d-learn mailing list