Robin Popplestone pop@roo.cs.umass.edu writes:
> Date: 30 Mar 2000 17:23:31 GMT
>
> A more systematic approach to system error handling would have other
> benefits. For example my Scheme implementation still has a few
> errors that are reported by the POP-11 error-reporting process.
> It would be beneficial to be able to plug in my own error messages
> in an easy way. Likewise it's sometimes desirable to catch
> mishaps and handle them in a non-standard way. For example
> one might extend the "+" function to produce a formal sum
> "x+y" represented, say, as a prolog term, if addition is given
> algebraic arguments.
You can do this using exitfrom, exitto, catch, throw, and redefining
prmishap, though it can be messy. See HELP CONTROL.
However, I noticed that in HELP NEWS, Apr 22 1996 there's an entry
describing a new exception handling mechanism, which I have never
used:
Apr 22 (John Gibson)
--- There is now a new mechanism for handling exceptions (mishaps
and warnings, etc). See REF?*?EXCEPTION for full details.
(These changes should be completely transparent to existing
programs, except in one respect: a redefinition of the procedure
interrupt that uses the test caller(1) == mishap to determine
whether it is being called from mishap rather than Ctrl-C will
no longer work (interrupt is now called from
sys_exception_handler). However, this test is no longer
necessary, since a program requiring different behaviour in the
Ctrl-C case can simply redefine *?keyboard_interrupt separately
from interrupt.)
Anyone who does not have the latest poplog and wants to read the
file referred to can look in
http://www.cs.bham.ac.uk/research/poplog/doc/popref/exception
(I've removed all Ved's special graphic characters from that file:
the bane of emacs users...). The code is in $popsrc/errors.p
On a very quick scan it looks as if the technique is very like
using catch and throw.
Aaron
|