3
votes

I love DrRacket IDE, but currently I'm building a pet project where I would like to be independent from it, meaning i'm commited to use only R5RS standard procedures.

The thing is, in DrRacket there's this procedure called "error" which i would like to continue using but I can't find it in the Standards.

What i would like to know is if there's a way to emulate that "error" procedure using only the Standards procedures so that the code is portable between different implementations of Scheme.

I've tried "display" but it doesn't seem to be quite what I want for that does not signal an error while outputting.

2

2 Answers

4
votes

This is the implementation that our lecturer gave us:

;;; create binding for error
(define error #f)

;;; capture toplevel continuation
;;;  assign a function to error, allowing a variable number of arguments to
;;;  be passed
(call-with-current-continuation (lambda (k)
              (set! error
                (lambda error-arguments
                  (display ">>>> ERROR ")
                  (newline)
                  (k error-arguments)))
              'done)) 
3
votes

Well, according to this: http://srfi.schemers.org/srfi-23/srfi-23.html, the error procedure is pretty widely available, so I think you would be safe using that.