Previous Table of Contents Next


11.8.2. Operation Syntax

The operators that have special syntax are classified and listed here in order of decreasing binding power:

Operator Description

x.a Infix dot
f(x) a[i] T{x} Applicative (, [, {
p^ Postfix ^
+ - Prefix arithmetics
* / DIV MOD Infix arithmetics
+ - & Infix arithmetics
= # < <= >= > IN Infix relations
NOT Prefix NOT
AND Infix AND
OR Infix OR

All infix operators are left associative. Parentheses can be used to override the precedence rules. Here are some examples of expressions together with their fully parenthesized forms:

Expression Parenthesized Form Reason

M.F(x) (M.F)(x) Dot before application
Q(x)^ (Q(x))^ Application before ^
- p^ - (p^) ^ before prefix -
- a * b (- a) * b Prefix - before *
a * b - c (a * b) - c * before infix -
x IN s - t x IN (s - t) Infix - before IN
NOT x IN s NOT (x IN s) IN before NOT
NOT p AND q (NOT p) AND q NOT before AND
A OR B AND C A OR (B AND C) AND before OR

Operators without special syntax are procedural. An application of a procedural operator has the form op(args), where op is the operation and args is the list of argument expressions. For example, MAX and MIN are procedural operators.

11.8.3. Designators

An identifier is a writable designator if it is declared as a variable, is a VAR or VALUE parameter, is a local of a TYPECASE or TRY EXCEPT statement, or is a WITH local that is bound to a writable designator. An identifier is a read-only designator if it is a READONLY parameter, a local of a FOR statement, or a WITH local bound to a non-designator or read-only designator.

The only operations that produce designators are dereferencing, subscripting, selection, and SUBARRAY. This section defines these operations and specifies the conditions under which they produce designators. In unsafe modules, LOOPHOLE can also produce a designator:

  r^—Denotes the referent of r; this operation is called dereferencing. The expression r^ is always a writable designator. It is a static error if the type of r is REFANY, ADDRESS, NULL, an object type, or an opaque type and a checked runtime error if r is NIL. The type of r^ is the referent type of r.
  a[i]—Denotes the (i + 1 - FIRST(a))th element of the array a. The expression a[i] is a designator if a is and is writable if a is. The expression i must be assignable to the index type of a. The type of a[i] is the element type of a.
An expression of the form a[i1, ..., in] is shorthand for a[i1]...[in]. If a is a reference to an array, then a[i] is shorthand for a^[i].
  r.f, o.f, I.x, T.m, E.id—If r denotes a record, r.f denotes its f field. In this case, r.f is a designator if r is and is writable if r is. The type of r.f is the declared type of the field.
If r is a reference to a record, then r.f is shorthand for r^.f.
If o denotes an object and f names a data field specified in the type of o, then o.f denotes that data field of o. In this case, o.f is a writable designator whose type is the declared type of the field.
If I denotes an imported interface, then I.x denotes the entity named x in the interface I. In this case, I.x is a designator if x is declared as a variable; such a designator is always writable.
If T is an object type and m is the name of one of T’s methods, then T.m denotes the m method of type T. In this case, T.m is not a designator. Its type is the procedure type whose first argument has mode VALUE and type T and whose remaining arguments are determined by the method declaration for m in T. The name of the first argument is unspecified; thus in calls to T.m, this argument must be given positionally, not by keyword. T.m is a procedure constant.
If E is an enumerated type, then E.id denotes its value named id. In this case, E.id is not a designator. The type of E.id is E.
  SUBARRAY(a: Array; from, for: CARDINAL): ARRAY OF ElemType(a)SUBARRAY produces a subarray of a. It does not copy the array; it is a designator if a is and is writable if a is. If a is a multidimensional array, SUBARRAY applies only to the top-level array.
The operation returns the subarray that skips the first from elements of a and contains the next for elements. Note that if from is zero, the subarray is a prefix of a, whether the type of a is zero based. It is a checked runtime error if from+for exceeds NUMBER(a).
Implementations may restrict or prohibit the SUBARRAY operation for arrays with packed element types.


Previous Table of Contents Next