[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Catch & Throw
As Craig Chambers mentioned, SELF has exit and exitValue to provide "catch & throw" capability. Parc Place Smalltalk versions 2.5 and later provide exception handling capabilities. This is a superset of catch & throw (essentially named catch and throw).
One problem I had with SELF's exit and exitValue was that it doesn't seem to work when an _Eval is on the stack. I was trying to implement an evaluator (which I will be sending to self-interest as soon as I've prettied it up a bit) which reads user expressions and evaluates them. The problem is that returning from a block whose context is down the stack a ways (which is what exit and exitValue do) doesn't work when there is an _Eval on the stack. It has no effect. It seems that the _Eval is done on a separate stack. This makes it difficult to handle compile errors. The only approach I can think of is to actually parse the expression! Run-time errors shouldn't be a problem. The _ReturnFromSelf primitive didn't seem to work either, although the documentation mentions that the _AbortFromSelf primitive also aborts any running primitives (such as _Eval). If anyone has a way around this problem, I would like to incorporate a solution into the evaluator.