CSC 530 Assignment 4 --
Adding Advanced Features to the Lisp Interpreter
Add the following to the Lisp interpreter of Assignment 2:
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.
An ML signature for the updated Lisp xeval function is the following:
wherexeval = fn sexprin * alistin * options -> sexprout * alistout
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,
- lazy evaluation of unreferenced function arguments never takes place;
- 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/.
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.