I would like something like:
(cond ((< x 3) (and (display "Error Message") (exit)))
(else (foo y))
In other words I'd like to display a message and terminate when a condition is met. How can I do this? Is there such an exit function?
Thanks in advance!
SRFI 23 provides error
. For error conditions, doing that is much better than calling exit
, because it makes it possible for other code to catch the error and do error-handling. (Some implementations implement exit
as an exception anyway, but that doesn't take away from my point that using error
is more appropriate.)
SRFI 34 provides a more complete exception facility, and can be even more appropriate than error
.
R5RS Scheme, and prior versions, does not require an exit function, though most implementations provide one. R6RS Scheme does require an exit function. Even without an exit function, it is generally possible to arrange the control flow of your program so that it just "falls off the end" when it is finished. If you need an exit and your implementation doesn't provide one, you can build your own with call/cc.
On ChezScheme I type:
(exit)
It took me much less longer than exiting vim the first time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With