What is the standard way to throw and catch exceptions in R6RS Scheme? I’m looking for syntax that works in any version of Scheme (not just PLT) that implements R6RS.
R6RS guard syntax looks like it might fit the bill, but can somebody show me an example of how to actually use it?
The semantics of
guardis:There is an auxiliary
elseclause that we do not use here. The following sample simulates exceptions that could be raised by typical file IO operations. We install aguardto handle the exceptions:Test run:
There is a detailed description of exception handling with example code in Chapter 7 of R6RS.