Writing routines (GNU Algol 68 Coding Guidelines)

### 6.1 Writing routines ¶

Use routines liberally! Routines are cheap, very easy to write thanks to the excellent Algol 68 syntax for routine texts, and first-class citizens in the language. They also have access to the lexical environment. So if you find yourself wanting to write a macro in order to repeat some little calculation, just write a small procedure or operator instead.

Choose identifiers that are expressive of meaning in order to clarify both the intent of the procedure or operator and the code written that uses it.

Consider using overloaded operators in preference to procedures with united mode parameters to encourage users of the operator to create new versions of the operator for different parameter types, rather than leaving the users trying to figure out how to hack the united mode definition.

The high level of orthogonaliy of Algol 68 combined with the structural type equivalence and the nice compact syntax of declarers makes mode names way less relevant than in many other programming languages. In particular if a routine takes a parameter that is an united mode, and that particular united mode is either not used anywhere else or very short, just write the declarer, you don’t have to name it first.

Please make good use of the lexical block structure of the programming language: is is there to be used. In little local auxiliary routines, do not add arguments just to pass a value that is in the environment; rather, place the declaration of the auxiliary routine near the declarations of the values it accesses. If this is not possible, then it may be wise to judiciously pass those non-nearby values as arguments in order that the programmer be aware that non-nearby values are being accessed or possibly altered.