|P is for Practical|
Re: Re: Re: Re: Perl Idioms Explained: && and || "Short Circuit" operatorsby demerphq (Chancellor)
|on Oct 22, 2003 at 23:30 UTC||Need Help??|
Well, what I mean is that I dont see how in C the conditional is only evaluated once. I dont know enough about how C implements a case statement to say for sure But i dont see how a case statement could be implemented in such a way without adding a lot of code to the statement, which would potentially be far more expensive than converting it to a series of conditionals. For instance something like this
I would guess would get converted to something like
Or something like it. I just dont see how it could be handled otherwise. Perhaps the fact that it only operates on ints means that there is a neater optimisation. But if you extend switch to handle strings as it does in pascal then I think the situation becomes even more difficult.
Thanks to the CB for clarifying that switch only handles ints. That issue may make my ruminations on this invalid. I dont know. Id be interested to hear from someone that does. As I said, this issue confuses me. :-)
First they ignore you, then they laugh at you, then they fight you, then you win.