Case Range Statement ..

Walter Bright newshound1 at digitalmars.com
Mon Jul 6 22:24:16 PDT 2009


Tim Matthews wrote:
> The case range statement is currently this
> 
> case FirstExp : .. case LastExp :
> 
> Would it be ambiguous to the compiler if it was
> 
> case FirstExp .. case LastExp :
> 
> or even
> 
> case FirstExp .. LastExp :
> 
> 
> Considering that we can correctly identify a slice rather than decimal 
> by just giving it a priority:
> 
> a = b[3..6];

I'm tired of typing this multiple times, so please indulge me while I 
cut & paste from one of them:

Because

1.    case X..Y:

looks like

2.    foreach(e; X..Y)
3.    array[X..Y]

yet the X..Y has a VERY DIFFERENT meaning. (1) is inclusive of Y, and 
(2) and (3) are exclusive of Y.

Having a very different meaning means it should have a distinctly 
different syntax.



More information about the Digitalmars-d mailing list