Chapter 6: Runtime System

Scope with nested procedures

The above example contains a program in Pascal with nested procedure sort

readarray

exchange

quicksort

partition

Here we apply the most closely nested rule for deciding scoping of variables and procedure names. The procedure exchange called by partition , is non-local to partition . Applying the rule, we first check if exchange is defined within quicksort ; since it is not, we look for it in the main program sort .