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
falsein anandexpression, the result must befalse, therefore, the second operand is not evaluated.If the first operand is
truein anorexpression, 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 variableaisn’tundefined, you can use the followingif a != undefined and sin a > 0 then...In a strict language, the
"sin a"evaluation of anundefinedoperand results in an error, and you would need to break up the expression into twoifstatements:if a != undefined then if sin a > 0 then ...
