Women in Technology

Hear us Roar



Article:
  What I Hate About Your Programming Language
Subject:   C, C++, Java, maybe others - zeroth element arrays
Date:   2003-10-31 20:22:38
From:   bioinfotools
Response to: C, C++, Java, maybe others - zeroth element arrays

Both 0-based and 1-based indexing can be useful in different stituations. Personally, I think this is one of the things Pascal got right. In Pascal, you explicitly set both the upper and lower bounds of arrays, which are bounds checked. You make indices any valid integer range, including using 0 and negative values. This way you get both 0-based indices (to masquerade offsets), indices starting in 1, or indices ranging over precisely whatever you like (e.g. -100..100). From vague memory you could even index arrays with characters or elements of sets.