Short-Circuiting Logical Expressions
Following the convention in most other programming languages, logical expressions in MAXScript are short-circuiting or non-strict. This means only enough of the sub-expression is evaluated to determine the overall result:
If the first operand is
false
in anand
expression, the result must befalse
, therefore, the second operand is not evaluated.If the first operand is
true
in anor
expression, the result must betrue
, therefore, the second operand is not evaluated.
This saves execution time and enables useful shorthand notation.
FOR EXAMPLE,
if you want to calculate
"sin a"
if the value of variablea
isn’tundefined
, you can use the followingif a != undefined and sin a > 0 then...
In a strict language, the
"sin a"
evaluation of anundefined
operand results in an error, and you would need to break up the expression into twoif
statements:if a != undefined then if sin a > 0 then ...