CSC 530 Assignment 4

CSC 530 Assignment 4 --
Adding Advanced Features to the Lisp Interpreter



ISSUED: Monday, 20 May 2002
DUE: Friday, 14 June 2002


Overview

Add the following to the Lisp interpreter of Assignment 2:

  1. One of the two advanced features you defined in Assignment 3, Question 4.
  2. One of lazy evaluation or memoization.

You may implement these extensions in either Lisp or ML. If you choose Lisp, you may continue to use your own solution to Assignment 2, or a provided solution available starting May 20 in the files ~gfisher/classes/530/solutions/assmnt2/{xcheck,xeval}.l. If you choose ML, a solution to Assignment 2 written in ML is provided in the files 530/solutions/assmnt2/{xcheck,xeval}.ml.

Adding One of the Advanced Datatyping Features

To begin this part of the assignment, you will need to transliterate the Pascal-like syntax you designed for Assignment 3 into Lisp syntax. This should not be a big deal. The next step is to implement the semantics you defined in Assignment 3 in the Lisp interpreter.

The final step for this part of the assignment is to design test data to reasonably test the new feature. The tests should be succinct but thorough, in the style of the Assignment 1 and 2 test programs. Put labeling comments above segments of the test program indicating what is being tested.

Adding Lazy Evaluation or Memoization

An ML signature for the updated Lisp xeval function is the following:

xeval = fn sexprin * alistin * options -> sexprout * alistout
where

The option values enable the different types of processing; their absence disables the indicated form of processing. As an alternative to the options input parameter, you may implement two separate versions of the interpreter, one that runs in normal eager evaluation non-memoizing mode, the other that runs in either lazy or memoization mode.

The lecture notes introduce the basic concept of lazy evaluation and it is discussed further in the Hudak paper. With the "lazy" option specified as an input to xeval, the interpreter should switch from the standard eager form of Lisp evaluation to lazy evaluation. The implementation details of lazy evaluation are up to you. There are specific test data provided to exercise and verify the interpreter's ability to perform lazy evaluation.

In general terms, the test data verify that the interpreter can perform the two important forms of lazy evaluation discussed in the lecture notes. Namely,


  1. lazy evaluation of unreferenced function arguments never takes place;
  2. lazy evaluation of potentially infinite generator functions terminates with meaningful results.

The lecture notes also introduce the basic concept of memoization and it is discussed further in Hudak. With the "memoize" option, the interpreter should perform memoization, such that evaluation of the same function two or more times with the same arguments results in reuse of a memoized function value. As for lazy evaluation, there are specific test data to exercise and verify the interpreter's ability to perform memoization.

Test files for lazy evaluation and memoization are in 530/assignments/4/test-files/.

One Final Question

There is one written question to be answered for this this assignment:

Are the "lazy" and "memoize" options mutually exclusive? Explain why or why not.




index | lectures | handouts | assignments | examples | doc | solutions | bin