Is there ANY chance we can fix the bitwise operator precedence rules?

Adam Ruppe destructionator at gmail.com
Mon Jun 21 17:40:14 PDT 2010


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.


I'm quite serious here: fallthrough is the defining feature of the
switch. Taking it away leaves you with nothing that if/elseif can't
already do. Might as well just axe the whole thing.

Oh yeah, the final switch would still be useful, since it offers a
check that if/elseif doesn't, but meh, move it to std.typecons, since
it is mostly for enums anyway.


(I'm not actually for removing the switch. I'm firmly in the status quo camp.)


More information about the Digitalmars-d mailing list