I’m working on a very high-level domain specific language that deals with data analysis. There is virtual uniform agreement that one-based indexing is the way to go from a scientific perspective. Of course programmers hate this mismatch, but virtually all our users are used to using x[i] to denote the element i not element i-1.
Are there any design principles that can be used to preserve some sane interoperability story with the CLR? My sense was that if we automatically translate System.Collections space with one-based variants, along with our C# based APIs we should be 90% of the way there. But I’m not sure. For instance, should we automatically rebase the IList interface? But what happens then if the C# API implements CustomRemove(zeroBasedIndex)?
Is there anything else we can do to ease this painful mismatch? How far should we go in making System.Collections one based.
Finally, are there any examples of one-based languages on the CLR?
Option 1: Burn an entry in your list. Set element 0 to a null value and all logical indexes start at 1.
Option 2: Create your own wrapper for the list and have its getter and increment the index for you.