Improvement to switch-case statement

Yigal Chripun yigal100 at gmail.com
Wed Dec 31 14:45:39 PST 2008


Mike James wrote:
> Just an idea that could improve Ds switch-case statement - add an elipsys as in object Pascal to allow case ranges.
>
> switch (var) {
>      case 1:
>          \\ do something
>          break;
>      case 2..10:
>          \\ do something else
>          break;
> }
>
> What do people think?
>
> -=mike=-

vote--

IMO, either the switch statement should remain the low level 
(effiecient) construct as in C, or replaced by a general mechanism of 
pattern matching. your solution is kinda between the two above options 
and I don't see the point of it.

I'd personally prefer pattern matching to be added to D and the switch 
to be deprecated and eventually removed from the language.



More information about the Digitalmars-d mailing list