Case Range Statement ..

Bill Baxter wbaxter at gmail.com
Tue Jul 7 10:00:01 PDT 2009


On Tue, Jul 7, 2009 at 9:48 AM, Derek Parnell<derek at psych.ward> wrote:
> On Tue, 07 Jul 2009 11:01:12 -0500, Andrei Alexandrescu wrote:
>
>> To me they look the same, but if people are happier with wasting
>> vertical space, sure.
>
> I think I've finally worked out why I don't like this syntax. Consider this
> ...
>
>
>   switch (X) {
>      case 1: funcA(); break;
>      case 2,5,7,10 .. 17, 24, 32: funcB(); break;
>      case 3,6,8,18 .. 23: funcC(); break;
>   }
>
> In other words, allowing a range of value inside a list of values.
>
> How is this possible in today's D?

By adding the word "case" several more times.

I really wish we would just go with two-dots for exclusive, three-dots
for inclusive, and make that work consistently everywhere.

The "too similar to see the difference" argument just doesn't hold
weight with me.  Unless you're programming in a proportional-width
font the difference is pretty obvious.  Or define some other char
sequence to mean inclusive range.  Like  a ..|b  or a..:b or a..^b,
etc.

--bb



More information about the Digitalmars-d mailing list