case statement allows for runtime values,
bearophile
bearophileHUGS at lycos.com
Tue Apr 19 14:13:22 PDT 2011
Andrej Mitrovic:
> Got it. Bug is reported.
Good.
> You can compare anything in an if statement, so why is switch more limited?
switch has stronger requirements than a series of if statements and its uses such extra information to create assembly code that's more efficient than a series of if statement, like a dense jump table. (And in some situations there are ways to produce something even better, if you need to emulate a state machine or an interpreter. You are able to do it in GCC with computed gotos).
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list