NET/MASTER Network Control Language (NCL) Reference Manual
An Overview of Expressions
Expressions and Operators
10–4 106126 Tandem Computers Incorporated
During expression evaluation, all arguments and intermediate results can be thought
of as being stored as character strings. Operators that require numeric operands
convert the operands to numbers. This is discussed later in this section in “Automatic
Type Conversion.” Expressions are evaluated according to the order of precedence of
operators. The precedence of operators is listed in “Precedence of Operators,” later in
this section.
Expression Optimization During compilation, expressions are optimized. Optimization includes the following:
Concatenating constant strings
Rearranging expressions when they contain separated constant operands
Performing operations when an operator has constant operands (“constant
folding”)
Converting alphabetic characters in labels, procedures, functions, and variable
names from lowercase to uppercase letters
The optimization process can rearrange operations involving the arithmetic addition
(+), subtraction (-), multiplication (*), and division (/) operators. This occurs only
when rearrangement does not affect the algebraic result of the expression (see
“Precision of Numbers,” later in this section, for more information). NCL performs
constant folding when an operator has constant operands. For example, the compiler
rearranges the expression 1 + &a + 2 to 1 + 2 + &a and adds the constants to give 3 +
&a.
You can use the parentheses to alter or force the evaluation order, if you wish.
Automatic Type
Conversion
A value can be of two types—string or numeric. The numeric type includes the
sub-types: floating point, integral, and Boolean.
The type associated with a value depends on context, and conversion from string to
number or from number to string is handled automatically by NCL. For example, in
the following statement, the value of 0023 is a string and the string 0023 is displayed
on the screen:
SAY 0023
However, in the following statement, the value of 0023 is treated as numeric and the
number 28 is displayed on the screen:
SAY 0023+5
When NCL attempts to convert a string to a number, it strips the string of leading and
trailing blanks and removes any blanks after a leading plus sign (+) or minus sign (-).
If the string is in a context that requires it to be numeric, the compiler produces an
error if it is not a correctly formatted number. NCL can always convert a number to a
string.
Type Conversion and Arithmetic Operators
The arithmetic operators require the operands to be numeric.