[Nickle] Exceptions with multiple arguments

Keith Packard nickle@nickle.org
Thu, 05 Dec 2002 08:10:25 -0800


Around 10 o'clock on Dec 5, Carl Worth wrote:

> In my current program it appears that in the catch block the formals
> are bound in reverse order.

Yes, they were.  Too many twisty indices.  Nickle used to evaluate 
function actuals from right to left (as C does).  With the 
"regularization" of evaluation (*everything* is evaluated left to right),
all of the argument ordering had to be flipped around and it looks like 
this one only got half finished.

>	$ nickle broken_exceptions.5c 
>	Stack underflow$

Oops.  The exception handler registers a continuation to jump to when the 
exception occurs; part of that continuation is the value stack.  The 
problem was that in raising an exception, the interpreter cleaned the 
actuals from the thread stack, but the stack that got "cleaned" was the 
stack from the continuation, rather than the stack from the raise.  
Exceptions with a single argument cleaned 0 items from the stack and so 
didn't cause a problem.  Exceptions with more arguments would attempt to 
remove values from an empty stack and cause a fatal interpreter error.

-keith