On Tue, 22 Jun 2010 02:40:14 +0200, Adam Ruppe <destructiona...@gmail.com>
wrote:
What's the point of a switch without implicit fallthrough? If you take
that away, it offers nothing that if/elseif doesn't. (Aside from not
retyping the switch(stuff here), which you can bring into a function
anyway, so whoop-de-doo. And I guess some performance boosts in
rearranging the cases, but can't the optimizer do that in if/else
anyway?)
int Case(in int value) { return myvar == value; }
if(Case(10)) {
} else if (Case(20)) {
} else { /* default */ }
You can even use goto and labels to simulate goto case.
Well, if you like sacrificing clarity for writing more verbose
code, feel free.
Switch is valuable for its clarity - '} else if (Case(12)) {' is
nowhere near as easily parsable as 'case 12'.
--
Simen