Class 15: Implementing Scope in Function Calls


Display version (pdf).



Reading (for next class): PLP, Section 8.3. Everything from "Closures as Parameters" (p. 401) on is optional - but I think the stuff in 8.3.3 is pretty interesting and worth reading!


  1. Draw the Central Reference Table after each call to function foo in the following code - that is, right after the call is made and the CRT is updated, but before the body of foo actually starts executing. Note that because foo is recursive there are three such calls.
      new x := 10;
      new i := 5;
      new foo := lambda x { 
        if (x = 1) { ret := 3; } 
        else { ret := 3*foo(x-1); } 
      write foo(3);