some people think array indices should start at 0 because it makes the pointer maths more efficient. others say they should start at 1 because that’s clearer to programmers. i say they should start at 2, as a compromise,
The obvious solution is for all arrays to start at ω, the first inaccessible ordinal. Then subsequent values are ω+1, ω+2, ω+3 and so on, and higher dimensional arrays can be indexed by an appropriate ordinal, formed as a product like (ω+1)(ω+1), (ω+2)(ω+2), (ω+3)(ω+3) and so on (I am just naming the diagonal entries of a 2D array). This convenient and rigorous scheme has a number of bonuses, including:
- easy multidimensional indexing with just ordinals, like C-style arrays
- you never have to say zeroeth element, since numbering intuitively starts on the ωth element.
- you can always tell what dimension of array you're indexing in, but your column operations cannot overflow into the next axis. Handy!
- easy to explain to CS undergrads, by simply making them take a topology course and shifting the problem to a different department.
- cannot actually be implemented on finite hardware, so any fully compliant implementation necessarily admits no runtime bugs.