Assignment 4 - Representation Independence and Dynamic Scope


This assignment comprises three parts.

Part I:

Write an interpreter that is representation-independent with respect to both environments and procedures. You must define two versions of the closure and apply-proc helper functions: one which uses higher-order (that is, functional) representation of procedures, and another that uses data-structural representation of procedures. You may use either data-structural or procedural representation of environments.

You must test your interpreter, using both sets of procedual helper functions. At a minimum, you should run the following test:
(test 'fact
  (value-of
    (quote
      ((let ([! (lambda (!)
                  (lambda (n)
                    (if (zero? n)
                      1
                      (* n ((! !) (sub1 n))))))])
         (! !))
       5))
    (empty-env))
  120)

Part II:

You will then add dynamic scope to your interpreter.

Part III:


Place your code from Parts I and II (including any test programs), and your description from Part II, in a file named a4.scm and submit it to Vincent. Comment-out your description using semi-colons (;), so that your file loads under Chez.


There are two brainteasers this week--try either one, or both! (Extra credit given only if you have completed the rest of the assignment.)