When using DrScheme with R5RS, there is no error function. I plan to write my own, but can't figure out how to halt the program execution. I tried commands such as:
- (halt)
- (exit)
- (error)
and none worked. How do you halt program execution?
When using DrScheme with R5RS, there is no error function. I plan to write my own, but can't figure out how to halt the program execution. I tried commands such as:
and none worked. How do you halt program execution?
SLIB (the portable Scheme library) has an implementation of ERROR. You might want to either look at that, or use SLIB in your programs.
Other than that, one way to halt the program is simply to raise a different error! Try something like this (thanks to Stephen Houben):
(define (error reason . args)
(display "Error: ")
(display reason)
(for-each (lambda (arg)
(display " ")
(write arg))
args)
(newline)
(scheme-report-environment -1)) ;; we hope that this will signal an error
While this does raise a second (unrelated) error, it will surely halt program execution.
Is there a reason you need to use R5RS? Other language definitions in DrScheme define error
and exit
. For example, the (module ...)
PLT language defines error
and exit
. Invoking mzscheme
from the command line also gives you these definitions.
Note: I have DrScheme 372, which is pretty old. Things shouldn't have changed too much, though.