Case Range Statement ..

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Jul 8 16:12:02 PDT 2009


Jérôme M. Berger wrote:
>     So, the correct way to define an inclusive range is with "+1" except 
> when it's with "nextUp", unless you're talking about the right end of 
> the range where it is inclusive by default and the right way to make it 
> exclusive is with "+1" except when it's with "nextUp"?
> 
>     That's what I call consistent!

I completely disagree with your assessment. First, you didn't mention
what the range is supposed to do. For example, what primitives should
the range have? Are you talking about a built-in type or a
library-defined type? etc.

There are two places in the language where expression1..expression2
comes into play: when slicing an array, and when iterating with foreach.
In both cases the range is discrete with step 1, and so it makes sense
to discuss that when expression1..expression2 is being talked about. Now
you can't just silently redefine what you mean by range and then claim
inconsistency.

If you want to make a case, please state clearly what are you talking
about. Nobody can be consistent with a definition that doesn't exist.


Andrei



More information about the Digitalmars-d mailing list