DrRacket, R5RS and the error procedure

不想你离开。 提交于 2021-02-19 03:50:05

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/3120379/drracket-r5rs-and-the-error-procedure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!