## CS430/530 Assignment 7

Due: Wednesday, December 4, 2013

1. Write a function to simulate the "try ... catch ..." exception-handling construct using letcc/throw. The function should have the following type:
$trycatch : \forall t_1.\forall t_2.(t_2 \; cont \to t_1) \to (t_2 \to t_1) \to t_1$
The expected behavior for an invocation is as follows: $trycatch \;(body) \; (handler)$ should pass a continuation $k$ to $body$ and proceed to evaluate it; if $body$ evaluates to $a$ then that should be the result of the overall expression; if $body$ throws a value $b$ to the continuation $k$ then the result of the overall expression should be $handler \; (b)$.

2. Reynolds, exercise 12.4. Use letcc/throw instead of callcc/throw, and have $test$ return pairs of natural numbers $\langle n_1, n_2 \rangle$ instead of $@ \; n_1 \; n_2$. The type of $F$ is $(nat \to nat) \to (nat \to nat) \to nat$.

3. Write a final project proposal (no more than one page). Project ideas can be found in the Projects page, but not restricted to those listed. You are also highly encouraged to talk to or email the professor and/or the TA about your ideas and the scope of the project.

### Sample Solutions

Sample solutions are here and here as well as on the Zoo machine /c/cs430/as/as7/as7-sol.*.