switch() needing break; is a design flaw. if() doesn't need it because if you have multiple statements, you just enclose them into curly braces.
Also break; can be used in for(), while() and do-while() in order to prematurely end them.
I read somewhere that it should have been designed to break automatically at every next case label and requiring some fallthrough keyword in the case that's what a programmer wants. How often do you notbreak; your cases?
I don't fully agree, as it's quite common for me to have 6-10 cases that all share the same code:
1 2
case x: case y: case z: case a: case b: case c:
// ...stuff
vs.
1 2 3 4 5 6 7
case x: continue;
case y: continue;
case z: continue;
case a: continue;
case b: continue;
case c:
// ...stuff
That said... it might be better to require the 'continue' only if there's a sequence point between case statements:
1 2 3 4 5 6
case a:
dosomething(); // semicolon here
continue; // <- so we need a continue
case b:
// <- nothing here
case c: // <- so no need to continue
But then that makes the rules more inconsistent and error prone.
On the other hand I agree that switch automatically falling through is not ideal. I just don't know what the best solution is, because all of them are kind of junky.
You would have to use something other than continue, that would be far to confusing...on the one hand cause control to pass to the end of a loop but on the other you would just move on to the next statement.