3.1 Subroutine tracing

Tracing the execution of a subroutine requires some effort. This is because we need to indicate the line to return to as a column that belongs to the subroutine. This column does not exist until the subroutine is called. The trace of algorithm 1 is in table 1.


Table 1: A trace of algorithm 1.
line #   comments
4   first line out of a subroutine
5 abc subroutine ``abc'' stores the line # to return to
  return line #  
  6  
2   the only line in the subroutine to execute
3 return we are ready to return, use the stored return line #
6   now we are back to the invoker's (caller's) code


Copyright © 2006-10-12 by Tak Auyeung