[Submission] D Slices
KennyTM~
kennytm at gmail.com
Tue May 31 13:43:58 PDT 2011
On Jun 1, 11 03:58, eles wrote:
>> Array indices do not form a field in D. What's the point bringing it
> in?
>
> Yes, they are (it is true no matter that we speak of D or not). Or,
> more exactly, they should be a field. They are numbers, after all.
>
No they aren't. If it is a 'field' as in Z_8, then we should have a[7]
== a[-1] == a[15], which is not true (the other two throw RangeError,
and practically they should). Indices are simply the subset "[0, 8) & Z"
of all accessible integers.
(Actually Z_8 is just a commutative ring, not a field. A field has much
more requirement than having addition and multiplication. Please
understand the term before you use it.)
> Secondly, why they should not be a field? Yes, the current approach
> introduces a "n+1"th parameter needed to characterize an array with
> just... n elements. Why that?
>
>
'a[i .. j]' means a slice containing elements a[k] where k in [i, j). No
j+1 involved :)
More information about the Digitalmars-d
mailing list