Product Site

1.11.2. Operators

An operator is a representation of an operation, such as an addition, to be carried out on one or two terms. Each operator, except for the prefix operators, acts on two terms, which can be symbols, strings, function calls, message terms, intermediate results, or subexpressions. Each prefix operator acts on the term or subexpression that follows it. Whitespace characters (and comments) adjacent to operator characters have no effect on the operator; thus, operators constructed from more than one character can have embedded whitespace and comments. In addition, one or more whitespace characters, if they occur in expressions but are not adjacent to another operator, also act as an operator. The language processor functionally translates operators into message terms. For dyadic operators, which operate on two terms, the language processor sends the operator as a message to the term on the left, passing the term on the right as an argument. For example, the sequence
say 1+2

is functionally equivalent to:
say 1~"+"(2)

The blank concatenation operator sends the message " " (a single blank), and the abuttal concatenation operator sends the "" message (a null string). When the ¬ character is used in an operator, it is changed to a \. That is, the operators ¬= and \= both send the message \= to the target object.

For an operator that works on a single term (for example, the prefix - and prefix + operators), Rexx sends a message to the term, with no arguments. This means -z has the same effect as z~"-".

See Section 5.1.4.2, “Comparison Methods” for comparison operator methods of the Object class and Section 5.1.7.18, “Arithmetic Methods” for arithmetic operator methods of the String class.

There are four types of operators:
  • Concatenation
  • Arithmetic
  • Comparison
  • Logical