Hacker News new | ask | show | jobs
by Avshalom 3559 days ago
Pascal and Ada have had arbitrary indexing for decades. It's been fine.
3 comments

And Fortran, where it works fine. Perl lets you change the array index offset but everyone warns you that your computer will reach out and slap you in the face if you do. As is often the case, the devil is in the details.
In perl is it APL style where it changes the index for the entire world (until changed again) or is it Fortran/Pascal style where you are expected to declare the lowest/highest index per array?
APL-style with a global index origin ($[ in Perl, à la ⎕IO in most APLs).
Pascal and Ada don't usually use their arrays as matrices in mathematical expressions. Julia is targeted at people using Matlab.

How do you multiply two matrices that use different indexing? Ignore the indexing differences?

It's also problematic when different libraries use different conventions (0-based vs 1-based). Can you use the output of one such library to feed another?

Ada has the notion of attributes applying to types and variables, to access related properties. Among those, there are attributes to get the starting and ending indexes of an array. So it's possible to program completely generic array processing, independent of the underlying choice or range for the array. All this from memory, and it's been a long time...
Eiffel too IIRC (same family I suppose)