CS 3520 Homework 8   - Due October 25

Exercise 8.1, Parameter-Passing Variations

Given the following expression in the interpreter language from class:
  let x = 0
      f = proc(y) set y=+(y,y)
   in let z = { set x=+(x,1) ; x }
       in { (f z) ; z }
what does the expression produce in the following configurations of the interpreter?
  1. All procedure arguments are call-by-value.
  2. All procedure arguments are call-by-reference (even without the &).
  3. All procedure arguments and let bindings are call-by-name.
  4. All procedure arguments and let bindings are call-by-need.
  5. All procedure arguments and let bindings are both call-by-name and call-by-reference (a bizarre combination).
Your task: Express your answer as a function named answer-for-8.1 that returns a list of five numbers, one for each part above (in order). Include the function with the modified interpreter for 8.2.

Check: The sum of the numbers in the list should be 11.

Exercise 8.2, Parameter-Passing Variations in an Interpreter

Start with this code, which defines a call-by-need interpreter like the most recent one in class.

In addition to the interpreter, the starting code defines four boolean variables:Only one of the first three can be #t at any time, but the fourth is independent of the others.

Your task: Modify the interpreter so that its behavior depends on the configuration of the four boolean variables:For example, you will need to modify eval-let-rands as follows:
  (define eval-let-rands
    (lambda (rands env)
      (map (lambda (x) (if call-by-value?
                           (evaluate-expression x env)
                           (thunkify-expression x env)))
           rands)))
The code in 8.1 provides a useful test case for your modified interpreter

When you hand in the code, the values of the boolean variables do not matter. We will set the variables when testing your interpreter.


Last update: Thursday, October 19th, 2000
mflatt@cs.utah.edu