About switch case statements...
    bearophile 
    bearophileHUGS at lycos.com
       
    Mon Nov 16 02:43:00 PST 2009
    
    
  
KennyTM~:
> switch (x) {
>    case 2:
>      doSomething();
>          // At this point:
>          // Compiles fine in C.
>          // Falls through to the next (irrelevant) branch.
>          // Compile-time error in D (missing "break;" or "goto case 3;")
>    case 3:
>      doSomeTotallyDifferentThing(x, ~x);
>      break;
>    ...
> }
Nice idea. 
"goto case 3;" isn't the nicest syntax to step to the following case, but it has the advantage that it keeps working if you shuffle the cases.
So this design is acceptable, avoids introducing a third version of switch, keeps the minimal compatibility necessary for C. If other people like it, then it may be implemented in D2.
Anyone sees disadvantages?
Bye,
bearophile
    
    
More information about the Digitalmars-d
mailing list