| Assigned: | Tue, Nov 22 |
|---|---|
| Due: | Thu, Dec 1 |
The original assignment 4 was split into two: this assignment includes both pair/unpair and letrec
For this problem, you will extend the lexical-address calculator discussed in lecture 4, and which may be copied (and renamed) under your CS account from the command prompt as follows:
$ cp -r /home/cs235/interps/lecture04/lexaddr-lang ./ $ mv lexaddr-lang/ assign4/
Each problem is worth 5 points.
letrec-exp and nameless-letrec-exp. You will have to write something like extend-nameless-env-recursively, and in this procedure you may use the same kinds of Scheme primitives that were used for this in the lecture notes. Exercise 3.40 [**] Extend the lexical address translator and interpreter to handle letrec. Do this by modifying the context argument to translation-of so that it keeps track of not only the name of each bound variable, but also whether it was bound by letrec or not. For a reference to a variable that was bound by a letrec, generate a new kind of reference, called a nameless-letrec-var-exp. You can then continue to use the nameless environment representation above, and the interpreter can do the right thing with a nameless-letrec-var-exp.
As in the notes, the output of your translator should be a program with no identifiers in it, and your interpreter should be able to evaluate the output of your translator.
Test your solution by running it on the tests in tests.scm, plus the tests you added for “pair” and “unpair”, as well as the “letrec” tests from Assignment 3.
Turn in a single package with all of your new specification rules, your extensions, and your tests.
submit235 script