Exceptions with the Hanson-Lamping algorithm

The revision previously mentioned about using the Hanson-Lamping algorithm has to take exceptions into account obviously. Exception handlers registered through on-err would reside on their own stack, the elements of which consisting of vectors with the following entries:

  1. The closure of the exception handler itself
  2. The current continuation for the call to on-err
  3. The current value of the here stack (TCH) of the current thread

Exceptions are raised by checking the top of the exception handler stack. If it is empty, the default exception handling behavior is executed. Otherwise, the top stack entry is obtained, and the following occurs:

  1. The TCH is rerooted to the saved value of the TCH preserved when the exception handler was created
  2. The functions thus obtained are executed, so all functions registered by intervening protect or dynamic-wind invocations get executed.
  3. The exception handler is removed from the top of the stack.
  4. The saved continuation (which was the continuation created by the call to on-err) becomes the current continuation.
  5. The exception handler is executed, with the exception that was raised as its argument

It seems that reference Arc handles the case of a protect clause raising its own error by catching the exception thus thrown, so the original exception is lost. That’s what this algorithm would do, if we do not remove the exception handler from the stack of exception handlers until after all the protect clauses are executed.

~ by stormwyrm on 2012-02-08.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: