Com Sci 221/321 --- Programming Languages
Assignment #7 --- Autumn 1999
Due Monday, 22 November


Last modified: Sun Nov 14 19:00:28 CST 1999

Com Sci 221 and 321

  1. Example 13.5 on pages 532-533 of the text shows a function f that produces different results under dynamic and static scope rules. Write another pure functional program defining a function that distinguishes the two scope rules, using only lambda, and no let. You may redefine the same function from the book, or design your own simpler example (e.g., without the multiplication). You may define your function f using define, but don't use additional defines within the definition of the function. Run your program to demonstrate that Scheme has static scope. Do a hand calculation for the same program from McCarthy's equations for the eval function in the pages of the LISP manual that I copied for you. Show that the old fashioned LISP had dynamic scope.


  2. Look at the weird higher-order examples that I did in Scheme. Translate them into ML and run them, observing the types. Notice which Scheme definitions fail in ML.

Com Sci 321 only

  1. Atomic symbols, lambda and function application are sufficient to define everything in LISP. We don't really need integers, lists, .... Redefine cons, car, cdr, the booleans T and F, and the special form if in terms of lambda and function application. Demonstrate your definitions on a few very simple examples.