NET/MASTER Network Control Language (NCL) Reference Manual
Precedence of Operators
Expressions and Operators
10–6 106126 Tandem Computers Incorporated
Precedence of
Operators
NCL evaluates expressions from left to right. It evaluates operators in expressions
according to their position and precedence. Operators that have the same precedence
are evaluated from left to right. Operators with a higher precedence are evaluated
before operators with a lower precedence. You can use parentheses to alter the
standard order of operation.
Table 10-1 shows the level of precedence for each operator, from highest to lowest, and
its type. Operators with the same level of precedence are grouped together.
Using Parentheses in
Expressions
This subsection describes how to use parentheses in expressions. Parentheses have the
highest precedence. An expression enclosed in parentheses is always evaluated first.
You can use parentheses in expressions to do the following:
Alter the order of evaluation
Delimit terms, especially when nested, to clarify the code
Delimit an expression that becomes the name of a local or external function
Blanks are deleted on the inside of a parenthesis: that is, to the right of the opening
parenthesis and to the left of the closing parenthesis. Thus, no blank operator exists in
these positions.
“Special Characters” in Section 8 explains how parentheses are processed by the
compiler.
Using Parentheses to Alter
Evaluation Order
The following table shows how you can use parentheses to alter the order of
evaluation of an expression and produce a different result:
Expression Result
(2 + 3 * 4 ** 2) 50
(2 + 3) * (4 ** 2) 80
((2 + 3) * 4) ** 2) 400
Using Parentheses to
Clarify an Expression
Using parentheses to delimit nested expressions is recommended for clarity. The
following example illustrates this:
(&a + (&b - (&c + &d)))
Using Parentheses When
Referring to a Function
You use parentheses when referring to a function through an expression. In the
following example, the name of the function is determined by the value of the variable
&number that is concatenated with FUNC:
&a = (FUNC||&number)()