Chapter 6: Runtime System

Parameter Passing .

. Call by name (used in Algol)

- names are copied

- local names are different from names of calling procedure

swap(i,a[i])

temp = i

i = a[i]

a[i] = temp

This is defined by the copy-rule as used in Algol.

1. The procedure is treated as if it were a macro; that is, its body is substituted for the call in the caller, with the actual parameters literally substituted for the formals. Such a literal substitution is called macro-expansion or inline expansion.

2. The local names of the called procedure are kept distinct from the names of the calling procedure. We can think of each local of the called procedure being systematically renamed into a distinct new name before macro-expansion is done.

3. The actual parameters are surrounded by parentheses if necessary to preserve their integrity.