[Submission] D Slices

KennyTM~ kennytm at gmail.com
Tue May 31 11:35:12 PDT 2011


On Jun 1, 11 02:24, eles wrote:
>> 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.
>

Array indices do not form a field in D. What's the point bringing it in?


More information about the Digitalmars-d mailing list