If statements vs case

Hershel Fisch hershf at rgllc.us
Mon Feb 26 15:18:06 EST 2007

On 2/26/07 2:27 PM, "Shao Sean" <shaosean at wehostmacs.com> wrote:

> There are differences between SWITCH and IF-ELSE-IF statements in other
> languages, but in regards to Revolution someone from the engine team
> would be best to answer it.
> In many languages SWITCH statements are converted into a hash table for
> much quicker lookups and using a SWITCH once or twice is slower than
> using an IF-ELSE-IF statement due to the SWITCH statement getting
> hashed, but using the same SWITCH statement multiple times will
> increase the speeds.
> Also, because of the fact that an IF-ELSE-IF statement is _always_
> evaluated, they can never be faster than a SWITCH statement (they can
> be just as fast, but never faster)
Sorry, what do you mean that IF-ELSE-IF is always evaluated?
Dosn't the "else" break it?
 end if
End if
> There are a few other differences between SWITCH and IF-ELSE-IF
> statements that do not seem to apply to  Revolution due to the fact you
> can use SWITCH statements just like an IF-ELSE-IF statement. Example;
> switch
> case (tLUET < 42)
>  # do something
>  break
> case (tLUET > 42)
>  # do something
>  break
> case (tLUET = 42)
>  # do something
>  break
> default
>  # do something
>  break
> end switch
> The above would usually need to be done with a IF-ELSE-IF statement
> but, as you can see, Revolution can do it as a SWITCH statement.
> -Sean
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the Use-livecode mailing list