开发者

DrRacket, R5RS and the error procedure

I love DrRacket IDE, but currently I'm building a pet project whe开发者_StackOverflowre 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.


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)) 


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜