[Submission] D Slices

David Nadlinger see at klickverbot.at
Tue May 31 12:56:58 PDT 2011


On 5/31/11 8:16 PM, eles wrote:
> == 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?

As far as I can see, there wouldn't be any problem with array.length 
being size_t.max in this example.

> 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).

The term you are looking for is probably »(weak) partial order«, whereas 
< is sometimes called »strict partial order«. I don't quite see how 
that's relevant here, though.

David


More information about the Digitalmars-d mailing list