Declaring New Inﬁx Operators
Date: 2020-10-07 18:10:00

Up | Next | Prev | PrevTail | Tail

### 7.22 Declaring New Inﬁx Operators

Users can add new inﬁx operators by using the declarations INFIX and PRECEDENCE. For example,

infix mm;
precedence mm,-;

The declaration infix mm; would allow one to use the symbol MM as an inﬁx operator:

a mm b instead of mm(a,b).

The declaration precedence mm,-; says that MM should be inserted into the inﬁx operator precedence list just after the − operator. This gives it higher precedence than − and lower precedence than * . Thus

a - b mm c - d means a - (b mm c) - d,

while

a * b mm c * d means (a * b) mm (c * d).

Both inﬁx and preﬁx operators have no transformation properties unless LET statements or procedure declarations are used to assign a meaning.

We should note here that inﬁx operators so deﬁned are always binary:

a mm b mm c means (a mm b) mm c.

Up | Next | Prev | PrevTail | Front