Monads and Nomads

Meaning

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 code:

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

It is clear that the second instance of plus refers to the monadic operator and the first instance refers to the dyadic operator. If one would write plusplus, it would be a third different bold tag.

However, 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.

The Revised Report defines the sets of monads and nomads as metanotions, referring to symbols in an abstract way using symbolical names like “is at most” or “plus i times”. These symbols do not always have a clear correspondence in click-able and printable symbols in all computers, so different implementations provide slightly different sets of monads and nomads. For example, in both GNU Algol 68 and Algol 68 Genie the set of monads is %^&+-~!? and the set of nomads is ></=*.

Now that we know about monads and nomads, we can give the precise rules to conform valid operator names in Algol 68:

Syntax

Simplified [RR 9.4.2.I,H] defines monads and nomads as metanotions:

H) MONAD ::  or; and; ampersand; differs from; is at most; is at least;
             over; percent; indow; floor; ceiling;
             plus i times; not; tilde; down; up;
             plus; minus; style TALLY monad.

I) NOMAD :: is less than; is greater than; divided by;
            equals; times; asterisk.

See Also