On 06/20/2010 09:00 PM, bearophile wrote:
Michel Fortin:
But what about the "case 1: ... case 10:" syntax?
switch (x) {
case 1: .. case 10:
case 22: .. case 32:
case 52, 64:
doSomething();
break;
default:
whatever();
break;
}
Sorry, in my first answer I have a bit partially misunderstood your question.
You can write that like this, but I think this is not compatible with the
current syntax (after commas you can of course add a newline):
case 1: .. case 10, case 22: .. case 32, 52, 64:
Otherwise you can keep them splitted (this needs no syntax changes):
case 1: .. case 10: goto case;
case 22: .. case 32: goto case;
case 52, 64:
One of my original proposals was this, that now can not be used:
case 1 ... 10, 22 ... 32, 52, 64:
The intent is to only require a control flow transfer if there is at
least one statement after the label.
Andrei