Best Practices in Rev development

Scott Kane scott at cdroo.com
Fri Jun 22 01:36:58 EDT 2007


----- Original Message ----- 
From: "J. Landman Gay" <jacque at hyperactivesw.com>

> It's more of a feature of "switch" statements. That's just how they work,
> in any programming language.

Not quite.  It may well be a feature of some - but not in general.  Take an
Object Pascal example (Borland Delphi):

procedure TMyButton.OnClick(Sender: TObject);
begin
    case MyNumber of
     0 : DoThisFunction;
     1 : DoThatFunction;
     2 : DoTheOtherFunction
     3: DoSomethingCompletelyDifferent;
   end;  //case
end;

Each element of the case statement is only evaluated of it is matches (in
this instance) the value of MyNumber.  Everything else is skipped.  You have
no break or exit statement as it's not needed and you could tack on an
"else" statement to handle the unexpected if desired.  Then of course there
is short circuit boolean evaluation which speeds everything up including if
statements by allowing only part of a statement to be read:

if not myBoolean = true then
DoSomething

If myBoolean is not false then everything is ignored as the compiler only
sees it if it is in fact not true - and so on.....

Scott




More information about the use-livecode mailing list