Essentials of Programming Languages (EOPL): Section 4.5.
You may work singly or in pairs on this assignment.
Be sure you mark (via comments) each change you make
to the interpreter files.
(See the Homework Policy
for more details.)
A copy of the source code of each file modified.
DO NOT turn in the source code from files you did not modify.
A run of your code that verifies that it passes all the tests in your test harness.
If you have more than one file to submit, bundle them into a zip or tar archive.
Click on
this
electronic-submission link,
and use your NetID and password for authorization.
Important: Make sure you select CIS 352 as the course
for which you're submitting.
(35 points) EOPL Exercise 4.32
(35 points) EOPL Exercise 4.34
(30 points) EOPL Exercise 4.39
Be sure to
include an explaination of why the program gives
different results under call-by-name versus call-by-need.
Re: Exercise 4.32. To make the procedures defined via
letrec multi-argument, you'll need to
change the definition of the environment datatype as
follows.
(define-datatype environment environment?
(empty-env)
(extend-env
(bvar symbol?)
(bval reference?)
(saved-env environment?))
(extend-env-rec*
(proc-names (list-of symbol?))
(b-vars (list-of (list-of symbol?)))
(proc-bodies (list-of expression?))
(saved-env environment?)))
Of course that is not the only change. For example,
the letrec
in the-grammar needs to be changed to:
(expression
("letrec"
(arbno identifier "(" (separated-list identifier ",") ")" "=" expression)
"in" expression)
letrec-exp)
Re: Exercise 4.34. value-of-operand will play
the same role here as in the call-exp case.
In your tests for this case, include
let x = 2 in letref y = x in begin set y = 100; x endwhich should return 100.
Re: Exercise 4.39. Remember that in our context, effects = variable-assignment.