Augustana University College

COMPUTING SCIENCE 370
Programming Languages


Algol-60 -- Control Structures



Hierarchical Control Structures and Structured Programming


LOCALIZED COST PRINCIPLE
Avoid distributed costs: users should only pay for what they use.

Parameter-passing Mechanisms

Algol supports two parameter passing mechanisms:


Note:

The example of an Algol for-loop given in the textbook (p. 138) uses the operator '/' instead of '÷' in the while clause, which actually causes the loop to print

   3 7 11 12 13 14 15 16 9 5 3 2 1 1 1 1 . . .

Three features of the specification of Algol 60 interact to produce this list of values:

  1. The step ... until statement steps the value of the loop control variable until it has passed the specified termination value, so i has the value 17 after the clause '11 step 1 until 16' finishes and before the clause 'i / 2 while i >= 1' starts (but the statement controlled by the loop is not executed for i as 17).

  2. The '/' operator in Algol operates on either real or integer arguments, but returns a real result. (The '÷' operator, on the other hand, operates only on integer arguments and returns an integer result.) This implies that i / 2 has the value 8.5 the first time the while clause is executed.

  3. The Revised Report on the Algorithmic Language Algol 60 specifies that a real value is to be rounded (not truncated, as in C and related languages) if it is to be assigned to an integer variable.


Copyright © 2000, 2001 Jonathan Mohr