[Submission] D Slices

eles eles at eles.com
Tue May 31 11:24:31 PDT 2011


> In my opinion it is natuaral to use half open intervals for zero-
based
> indices. My reasoning:
> //zero-based
> int[8] zero; //indices from 0 upto and excluding 8 -> [0,8)
> //one-based
> int[8] one;
> //in many languages the indices from 1 upto and including 8 -> [1,8]
> Then, using the same type of inetrval seems natural for slicing.
> Mafi

Well, in my opinion it is not, as from mathematical point of view,
1..N-1 is a *closed* field http://en.wikipedia.org/wiki/Field_
(mathematics) w.r.t. addition and multiplication.

It simply says that there are *no outside* elements. They are 8
elements, and they go from 0 to 7. "8" never appears among those
elements.



More information about the Digitalmars-d mailing list