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

Simen kjaeraas simen.kjaras at gmail.com
Tue Jun 22 05:14:45 PDT 2010


On Tue, 22 Jun 2010 02:40:14 +0200, Adam Ruppe <destructionator at 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


More information about the Digitalmars-d mailing list