Exceptions and Stack Rollback
Currently I am working on adding type-safe exception handling to Cat. The primitive function for exception handling is simply:
try_catch : (’A try=(’A -> ‘B) catch=(’A ‘c -> ‘B)Â -> ‘B)
The type variable ‘c represents the exception data. Â
Implementing exceptions means I need to be able to revert the stack back to a previous state. This will be done naively in the Cat interpreter by simply copying the stack and pushing it back if needed. When type checking is reenabled we can compute precisely how deep of the stack needs to be copied, since most of it will remain unchanged.