A procedure call is interpreted by performing the following steps:
- Lookup the procedure's definition in the procedure a-list.
- Evaluate <expr 1> <expr 2> ... <expr N>
to produce <val 1> <val 2> ... <val N>.
- Create a frame consisting of ((<var 1> <val 1>)
(<var 2> <val 2>)...(<var N> <val N>)).
- Push the frame onto the environment stack.
- Tail-call the interpreter on a program consisting of:
- <stmt 1> <stmt 2> ... <stmt M>
- A command to pop the environment stack.
- The rest of the calling program.
The environment stack can be popped at the right point by inserting a
special command, e.g., $pop-frame$, into the list of statements to be
interpreted. This should be inserted immediately after <stmt
M> and before the statements comprising the rest of the
program.