Subsections

Summary

The fact that this is one of the longer chapters in the book reflects the importance of routines in Algol 68 programs. Every formula uses operators, and procedures enable a program to be written in small chunks and tested in a piecewise manner.

A routine denotation forms the basis of both operators and procedures. Routine denotations have a well-defined mode, the value being the denotation itself. A routine can declare identifiers within its body, including other routines (whether operators or procedures).

Operators can have one or two operands (as the parameters are called) and usually yield a value of some mode other than VOID. Dyadic operators have a priority of 1 to 9. Firmly related operators cannot be declared in the same range. The operator symbol can be a bold indicant (like a mode indicant) or one of or a combination of various symbols.

Procedures can have none or more parameters of any mode, and can yield a value of any mode (including VOID). Procedures can call themselves: this is known as recursion.

Rows of procedures, names of procedures and other modes using procedure modes can all be declared and, on occasion, can be useful.

Here are some exercises which cover some of the topics discussed in this rather long chapter.


Exercises

6.28
At the time of the call of a procedure or operator, what is the relationship between the formal parameters and the actual parameters? Ans[*]
6.29
Write an operator which will find the largest element in its two-dimensional row-of-reals parameter. Ans[*]
6.30
Write a procedure, identified by pr, which can be called by the phrase pr(2)[2]. Ans[*]
6.31
Write a procedure which computes the length of a line read from the keyboard. Ans[*]


Sian Mountbatten 2012-01-19