Consult EOPL 2nd ed. text. Section 3.5 and Exercise 3.27 on Pages 84-91.
Now modify the interpreter code in 3-5.scm to support statically scoped user-defined procedures with the representation for closure as given in Exercise 3.27, and reproduced below.
(define (closure ids body env)
(let ((freevars
(set-diff (free-vars body) ids)))
(let ((saved-env
(extend-env
freevars
(map (lambda(v) (apply-env env v)
freevars)
(empty-env))))
(lambda (args)
(eval-expression body (extend-env ids args
saved-env))))))
)
Note that set-diff takes difference of two sets, and free-vars determines the set of free variables in an expression.
In order for me to better grasp the changes you made, comment out the code you are modifying, rather than deleting it. Include test calls and outcomes in your turned in solution so as to make it clear that you are exercising all the constructs.
What to hand-in?
Submit your well-documented solution in file named 3-5-modified.scm by executing the following turn-in command on unixapps1.wright.edu. (You can optionally include a separate README.txt.)
%/common/public/tkprasad/cs784/turnin-pa2 3-5-modified.scm