[Submission] D Slices
eles
eles at eles.com
Tue May 31 11:16:29 PDT 2011
== Quote from David Nadlinger (see at klickverbot.at)'s article
> On 5/31/11 6:10 PM, eles wrote:
> > Actually, I think 0-based vs. 1-based is of little importance in
the
> > fact if limits should be closed or open. Why do you think the
> > contrary?
> > Why it is "natural" to use open-limit for 0-based? I think it is
> > quite subjective. Why to the right and not to the left?
> for (int i = 0; i < array.length; ++i) {}
> array[0..array.length]
> David
First: what happens in your example if array.length=2^n-1, where n is
the number of bits used to represent i?
How would you increment ++i then?
Second:
for (int i = 0; i <= array.length-1; i++) {}
array[0..array.length-1]
I should note that from mathematical point of view, "<" is not a
relation of order, as it lacks reflexivity (meaning a<b and b>a does
not imply a==b).
Only <= and >= are relations of order, as they are also reflexive (as
a<=b and b<=a implies a==b).
More information about the Digitalmars-d
mailing list