CS 536 (F03) Homework 5: Implementing Exceptions

Due: October 13 in class (hardcopy)

Assignment Goals

Exercises: Implementing Exceptions and Lists

  1. The notes on implementing exceptions explain how to add exceptions to our language. Start from the following basic interpreter with environments and add lists and exceptions as outlined in those notes. You should be able to interpret the exception-based product program from the notes in your solution. Note that this means that you will also need to add recursion. Use the boxed-based approach that we discussed in class.

    The new concrete syntax elements are as follows:

       {try FWAE fun}
       {raise FWAE}
       {kons FWAE FWAE}
       {kar FWAE} 
       {kdr FWAE}
       {ifempty FWAE FWAE FWAE}

    where the fun in the try case (the handler) takes a single argument (the value raised by the exception.

    Your list implementation should be syntactic rather than meta. In other words, don't use Scheme \scheme{cons}, \scheme{first}, \scheme{rest}, and \scheme{empty} to implement these operators.

    I recommend doing this assignment in stages. Add lists first, then work on exceptions.

    As always, you should also include your own additional test cases.

Back to the Assignments page