"case X, Y" works for 3-4 values, but for something longer problems accumulate:
case SOME_BAD_THING, SOME_OTHER_CONDITION, HERE_IS_NUMBER_THREE:
foo();
int y = baz();
Placing them on the next row is fairly hard to read
case SOME_BAD_THING, SOME_OTHER_CONDITION,
HERE_IS_NUMBER_THREE, AND_NUMBER_FOUR, AND_NUMBER_FIVE,
AND_THE_LAST_ONE:
foo();
int y = baz();
In C I regularly end up with lists that have 10+ fallthroughs like this, because I prefer complete switches over default for enums at least.
case SOME_BAD_THING:
case SOME_OTHER_CONDITION:
case HERE_IS_NUMBER_THREE:
case AND_NUMBER_FOUR:
case AND_NUMBER_FIVE:
case AND_THE_LAST_ONE:
foo();
int y = baz();
I understand the desire to use "case X, Y:" instead, and I did consider it at length, but I found the lack of readability made it impossible. One trade off would have been:
case SOME_BAD_THING,
case SOME_OTHER_CONDITION,
case HERE_IS_NUMBER_THREE,
case AND_NUMBER_FOUR,
case AND_NUMBER_FIVE,
case AND_THE_LAST_ONE:
foo();
int y = baz();
But it felt clearer to stick to C syntax, despite the inconsistency.
although when working with enumerators, there is a still a risk caused by the fact that re-ordering enumerators or adding new ones can break the switches.
Despite of the drawback I prefer. Also a Range can be a formal expression which simplifies the grammar of other sub-expressions and statements, not only switches but also array slices, tuple slices, foreach, literal bitsets, etc.