Re: switch statement
- Posted by mattlewis (admin) Mar 26, 2009
- 1358 views
Critic said...
euphoric said...
Okay, now I remember why it was a good idea. SPEEEEEEEEEED!!!
Speed is no justification for a bad syntax (a "select" statement can be optimized just like a "switch"). Apart from that, an "if"-"elsif"-statement can be optimized into a jump table too.
Bad syntax is often subjective.
Not all if-elsif-else statements can be optimized this way (think side effectsbad practice, but still needs to be taken into account), but your statement is just referring to a trivial isomorphism between a switch and if-elsif-else blocks. By which I mean that all switches (that don't use fallthrough) can be trivially altered to be an if-elsif-else.
Matt