PLC: Assignment #9

This assignment is due on May 12th.

Question 1 (4 points)

What will be printed by following Scheme-like program under the assumption that parameters are passed call-by-value, call-by-reference, and call-by-value-return?

(define (parameter-demo)
   (define a 1)
   (define (f b)
      (set! b (+ b 1))
      (display "a = ")(display a)
      (display ", b = ")(display b)
   (f a)

Question 2 has been removed.

Question 3 (13 points)

Scheme provides the operations delay and force to support normal-order evaluation (or lazy evaluation). They are explained in section 6.4 of R5RS (on page 32). Explain the difference between call-by-name and normal-order evaluation as implemented by delay and force. Would it be possible to write Jensen's Device using delay and force?

Using delay and force it is possible to write a Y combinator in Scheme. Write one and demonstrate its use with the factorial function.

The first two of these questions are partly based on exercises out of Ellis Horowitz, ``Fundamentals of Programming Languages''.

Please submit everything in one email that includes all your answers in attachments. Multiple submission emails are permitted but then only the last one is considered.

Andreas F. Borchert, May 6, 2002