[Submission] D Slices

KennyTM~ kennytm at gmail.com
Tue May 31 11:29:51 PDT 2011


On Jun 1, 11 02:16, 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?
>
> 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).
>
>

If your program needs an array of 4 billion elements (2e+19 elements on 
64-bit system), you're programming it wrong.

This is an problem that won't arise practically. The advantages of using 
closed range is small compared with those of open range (as shown by 
other people).



More information about the Digitalmars-d mailing list