Date: 2020-10-07 18:10:00

Up | Next | Prev | PrevTail | Tail

## 15 Procedures

It is often useful to name a statement for repeated use in calculations with varying parameters, or to deﬁne a complete evaluation procedure for an operator. REDUCE oﬀers a procedural declaration for this purpose. Its general syntax is:

[⟨procedural type⟩] PROCEDURE ⟨name⟩[⟨varlist⟩];⟨statement⟩;

where

⟨varlist⟩ ::= (⟨variable⟩,…,⟨variable⟩)

This will be explained more fully in the following sections.

In the algebraic mode of REDUCE the ⟨procedural type⟩ can be omitted, since the default is ALGEBRAIC. Procedures of type INTEGER or REAL may also be used. In the former case, the system checks that the value of the procedure is an integer. At present, such checking is not done for a real procedure, although this will change in the future when a more complete type checking mechanism is installed. Users should therefore only use these types when appropriate. An empty variable list may also be omitted.

All user-deﬁned procedures are automatically declared to be operators.

In order to allow users relatively easy access to the whole REDUCE source program, system procedures are not protected against user redeﬁnition. If a procedure is redeﬁned, a message

*** <procedure name> REDEFINED

is printed. If this occurs, and the user is not redeﬁning his own procedure, he is well advised to rename it, and possibly start over (because he has already redeﬁned some internal procedure whose correct functioning may be required for his job!)

All required procedures should be deﬁned at the top level, since they have global scope throughout a program. In particular, an attempt to deﬁne a procedure within a procedure will cause an error to occur.

15.1 Procedure Heading
15.2 Procedure Body
15.3 Matrix-valued Procedures
15.4 Using LET Inside Procedures
15.5 LET Rules as Procedures
15.6 REMEMBER Statement

Up | Next | Prev | PrevTail | Front