The discussion on my previous post (Why numbering should start at one) suggests a new approach. Maybe these blogging tubes are good for something after all.
We access the elements of a sequence (AKA array, string) using a new immutable datatype called Ordinal. We can ask a non-empty sequence what the ordinals of its first and last elements are. The first ordinal of all sequences are equal, so we can define the literal constant first.
We can add an integer offset to an ordinal to get a new ordinal. We can subtract two ordinals to get the integer distance between them. But we can not add two ordinals together. Most importantly, we can not convert ordinals into integers or vice-versa.
Thus the question of whether to number starting at 0 or 1 is abstracted away. I conjecture that many fencepost errors are also eliminated by making a type distinction between ordinals and lengths, and preventing their direct interconversion. Ordinals can be seen as a special kind of collection iterator with a distance metric and a designated instance first.
Using integers as ordinals is rep exposure! Abstract data types rule.
Based on the conversation below I am retracting this proposal. It doesn’t really solve the problem of indexing conventions, just pushes it up a layer. Not worth the complexity. I am left still believing that that choice of index base is purely conventional, and that the widespread belief that 0-based indexing is superior is just a myth we inherited from Assembly Language which now serves mostly as a tribal marker. I would be happy to see some example that shows a real difference.