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

Up | Next | Prev | PrevTail | Tail

### 7.21 Declaring New Preﬁx Operators

The user may add new preﬁx operators to the system by using the declaration OPERATOR. For example:

operator h,g1,arctan;

adds the preﬁx operators H, G1 and ARCTAN to the system.

This allows symbols like h(w), h(x,y,z), g1(p+q), arctan(u/v) to be used in expressions, but no meaning or properties of the operator are implied. The same operator symbol can be used equally well as a 0-, 1-, 2-, 3-, etc.-place operator.

To give a meaning to an operator symbol, or express some of its properties, LET statements can be used, or the operator can be given a deﬁnition as a procedure.

If the user forgets to declare an identiﬁer as an operator, the system will prompt the user to do so in interactive mode, or do it automatically in non-interactive mode. A diagnostic message will also be printed if an identiﬁer is declared OPERATOR more than once.

Operators once declared are global in scope, and so can then be referenced anywhere in the program. In other words, a declaration within a block (or a procedure) does not limit the scope of the operator to that block, nor does the operator go away on exiting the block (use CLEAR instead for this purpose).

An operator declared PRINT_INDEXED has its arguments displayed as indices, e.g. after print_indexed a; the operator value a(i,2) is displayed as . You can declare several operators together to be indexed, e.g.

print_indexed b, c;

and remove indexed declarations using PRINT_NOINDEXED.

Up | Next | Prev | PrevTail | Front