On 5/31/11 10:10 AM, eles wrote:
I agree that the issue is not simple (else, there would have been no
"war"). I know no other examples where open-right limits are used. I
use (intensively) just another language capable of slicing, that is
Matlab. It uses the closed-left and closed-right limits and I tend to
see it as a winner in the engineering field, precisely because of its
ability to manipulate arrays (its older name is MATrix LABoratory and
this is exaxtly why I am using it for). Some examples of syntax
(arrays are 1-based in Matlab):

a=[1,2,3,4]; % array with elements: 1, 2, 3, 4 (of length 4)
b=a(1:3); %b is an array with elements: 1, 2, 3 (of length 3)
c=a(end-1:end); %c is an array with elements: 3, 4 (of length 2)
d=a(2:1); %d is empty
e=a(1:end); %e is an array with elements: 1,2,3,4 (of length 4)
f=a(1:10); %ERROR (exceeds array dimension)
g=a(1:1); %g is an array with elements: 1 (of length 1)

I agree that 1-based indexing works pretty well with closed-right intervals; forgot to mention that in my first response. Even with such an approach, certain things are less obvious, e.g. the number of elements in an interval a..b is b-a+1, not b-a.

All in all D doesn't attempt to break new ground with open-right intervals. It would be gratuitously and jarringly different from all of its major influencers. Though I understand the choice looks odd coming from Matlab, the same could be said about a lot of other languages.


Andrei

Reply via email to