This document discusses different techniques for implementing subprograms (subroutines and functions) in programming languages. It covers:
- The general semantics of subprogram calls and returns, including saving execution context, passing parameters, and transferring control.
- Implementing "simple" subprograms where local variables are static and nesting is not allowed, using static allocation of code and activation records.
- Using a call stack to implement subprograms with stack-dynamic local variables, recursion, and nested subprograms, where activation records are dynamically allocated on the stack.
- Techniques like static chaining and static depths to allow accessing nonlocal variables in nested subprograms by finding the correct activation record on the stack.