Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

Operator Precedence

You can combine the arithmetic operators to form complex mathematical expressions. You may be surprised to learn that ObjectScript's rules for operator precedence are different than those in other languages: there aren't any! Evaluation of an expression proceeds from left to right, without regard for operators.

But this difference really isn't important, because like other languages, you can use parentheses to specify which operations to perform in what order. Complex expressions should always be clarified by using parentheses, no matter which language you're using. Always use parentheses!


SAMPLES>set x = 3 + 5 * 6 - 4

SAMPLES>write x
44
SAMPLES>set x = 3 + ( 5 * 6 ) - 4

SAMPLES>write x
29
SAMPLES>
Feedback