4.5 Monads and Nomads

Algol68 operators, be them predefined or defined by the programmer, can be referred via either bold tags or sequences of certain non-alphabetic symbols. For example, the dyadic operator + is defined for many modes to perform addition, the monadic operator entier gets a real value and rounds it to an integral value, and the operator :=: is the identity relation. Many operators provide both bold tag names and symbols names, like in the case of :/=: that can also be written as isnt.

Bold tags are lexically well delimited, and if the same tag is used to refer to a monadic operator and to a dyadic operator, no ambiguity can arise. For example, in the following program it is clear that the second instance of plus refers to the monadic operator, and the first instance refers to the dyadic operator2.

op PLUS = (int a, b) int: a + b,
   PLUS = (int a): a;
int val = 2 PLUS PLUS 3;

On the other hand, symbols are not lexically delimited as words, and one symbol can appear immediately following another symbol. This can lead to ambiguities. For example, if we were to define a C-like monadic operator ++ like:

op ++ = (ref int a) int: (int t = a; a +:=1; t);

Then the expression ++a would be ambiguous: is it ++a or +(+a)?. In a similar way, if we would use ++ as the name of a dyadic operator, an expression like a++b could be also interpreted as both a++b and a+(+b).

To avoid these problems Algol 68 divides the symbols which are suitable to appear in the name of an operator into two classes: monads and nomads. Monads are symbols that can be used as monadic operators. Nomads are symbols which can be used as both monadic or dyadic operators. Given these two sets, the rules to conform a valid operator are:

In the GNU Algol 68 compiler:


Footnotes

(2)

If one would write plusplus, it would be a third different bold tag.