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

Leandro Lucarella luca at llucax.com.ar
Mon Jun 21 18:36:56 PDT 2010


Adam Ruppe, el 21 de junio a las 20:40 me escribiste:
> 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.)

Well, while, do..while are also redundant, you can do it with for. And
you can do for with goto!

The point is providing a nice syntax for common usage patterns, and
switch without fall-through is way more common than switch with
fall-through, even when fall-through might been the primary "feature"
provided by switch in its early ages.

And you can still use fall-through with the proposed semantics of
switch, it's just making it explicit instead of implicit.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
TIGRE SE COMIO A EMPLEADO DE CIRCO: DETUVIERON A DUEÑO Y DOMADOR
	-- Crónica TV


More information about the Digitalmars-d mailing list