[英]DrRacket, R5RS and the error procedure
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. 我喜欢DrRacket IDE,但目前我正在构建一个宠物项目,我想独立于它,这意味着我只想使用R5RS标准程序。
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. 问题是,在DrRacket中有一个叫做“错误”的程序我想继续使用,但我在标准中找不到它。
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. 我想知道的是,是否有一种方法可以仅使用Standards程序来模拟“错误”过程,以便代码可以在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))
好吧,根据这个: http : //srfi.schemers.org/srfi-23/srfi-23.html ,错误程序非常广泛,所以我认为你可以安全地使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.