|RPN in Algol 60|
Algol 60 is created in the late 1950's by an international group of computer scientists. It is one of the first universal, general-purpose, widely known and implemented programming languages ever; in fact, it is the second one (Fortran being the first).
The language has been used for some years, including as a primary vehicle of communicating algorithms in printed form, but never widely adopted in industry. Now out of use, but compilers and interpreters for it are available.
Initially, there have been several definitions of the language available, existing under names that were variations of Algol (for algorithmic language). Today, saying Algol associates with the formal name Algol 60. The definition of the language is given by the Revised Report on the Algorithmic Language ALGOL 60, extended and made more precise more than 15 years later by the Modified Report … (see the Links section below). The most important addition of the Modified Report with respect to the Revised was the Envionmental block – a set of standard procedures, notably some for input/output. The Revised Report did not specify anything of the sort!
Algol 60 is a model of concise and clear language definition.
The language pioneered a number of constructs:
own(i.e. static) local variables;
Most later imperative languages were strongly influenced by Algol 60.
An interesting feature of Algol 60 is the ‘call-by-name’ parameter binding mode, which is in fact the default – the other possible mode is value passing, explicitly specified by the keyword
value. In its basic use, calling by name is similar to calling by reference, but is more general. The effect of it is as if the actual argument is textually substituted for all the occurences of the formal parameter. This can be exploited in highly non-trivial ways, but also is a source of obscurity, and that is why calling by name has not been adopted in allmost any of the languages created after Algol. A popular example of applying the call-by-name is Jensen's Device.
Conditional or unconditional jump to another point in the program is possible through the
go to statement, which can take a label or an expression as an argument. The latter is bound to evaluate to a label anyway, but one can use a conditional expression or a switch as a means to select from two or more alternatives. Switches are vectors of labels which can be subscripted with integer values, similar to arrays.
The loop statement in Algol 60 is one, but by varying its elements it is possible to accomodate several common patterns of iteration. Its general form is
do…, where L is a list of items, each one either an arithmetic expression, or an
until or a
while clause. An
until clause, B
until E, implements an iteration over an arithmetic progression starting at B, with step S, and not exceeding E. A
while clause, A
while P, results in a loop controlled by a pre-condition P, with A evaluated and assigned to v each time before P is evaluated. If a separate initialization step is needed, the
while clause can be paired with a simple expression, such as in
There was some vacillation in the Algol committee as to whether the step expression of the
until clause should be evaluated only once at the beginning or before each execution of the loop body. Perhaps it is worth noting that, although the language definition describes the former behaviour, that decision was eventually considered a mistake. A version of the Modified Report exists in which the alternative variant was adopted, but for which it was too late to become the official language document.
It is rather strange that the loop statement is invariably bound to a control variable, even when it is not really needed, which is not uncommon with the
A curious and rare feature of Algol 60 is giving procedures, and calling them with, multi-part names, such as
sort(a) from index:(2) to index:(100). Formally, it is not that the name of the procedure is of many parts, but arbitrary delimiters of this form can be used in place of the more traditional comma for the sake of clarifying the text to the reader. To a compiler, those delimiters are no more meaningful than comments: the above call is indistinguishable from
Although very innovative for its time, by design Algol 60 was still, like Fortran, a language for processing numerical data. The only kinds of data a program can operate on are integers, reals, booleans, and arrays of them. No form of data aggregation other than arrays is available in the language, let alone user-defined datatypes. Particularly notable is the very limited presence of strings. Indeed, the language defines the notion of strings but leaves them almost unusable in practice. Here is why.
There are string constants but not string variables other than formal parameters within procedures. Actually, strings are not even values, since it is impossible to create new strings in the program. Besides, Algol's strings are monolithic: one cannot specify individual items within them (there is no character datatype anyway) or extract substrings. In fact, the only things one can do with strings are printing them, passing them as arguments to procedures, finding the length of a parameter string, and using them as reference tables in single-character input or output (rather than inputting a character per se, one obtains its index within the reference table; reversely for output). Even computing the length of the string in the presence of inner strings is implementation-dependent.
Similar to strings, other objects present in the language are ‘half-data’. Arrays, labels, switches, and procedures can be passed as arguments but are not assignable values, do not constitute datatypes, and cannot be the result of a procedure. The only true kinds of values, and the only datatypes in Algol 60 are integers, reals and booleans.
The Revised Report on the Algorithmic Language Algol 60, The Modified Report on the Algorithmic Language Algol 60, and other documents
Historical documents, implementations
MARST: GNU's Algol-to-C translator