Embedded switches?

Mark Wieder mwieder at ahsoftware.net
Mon Sep 21 16:03:43 EDT 2009


Richmond-

Monday, September 21, 2009, 12:48:58 PM, you wrote:

> I have to use either:

> 1. A multi-case switch statement with many sub-switch statements inside it,

> or

> 2. A multi-case switch statement with many IF . . . THEN statements 
> inside it,

> or

> 3. Many IF . . . THEN statements with many IF . . . THEN statements 
> inside them.

> Number 3. is obviously going to slow things down a ton!

Actually there's no speed penalty for if/then vs switch constructs.
They compile down to the same comparisons. If you're going to be
applying the same tests repeatedly then you may find a negligible
difference, but overall I wouldn't worry about this.

> Should I choose 1. or 2 ?  and why?

I usually find that switch statements are more readable after the fact
than nested ifs, but others may have other opinions about this.

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list