DrRacket、R5RS和错误程序

发布于 2024-09-07 05:42:47 字数 230 浏览 1 评论 0原文

我喜欢 DrRacket IDE,但目前我正在构建一个我希望独立于它的宠物项目,这意味着我致力于仅使用 R5RS 标准程序。

问题是,在 DrRacket 中有一个名为“错误”的过程,我想继续使用它,但我在标准中找不到它。

我想知道是否有一种方法可以仅使用标准过程来模拟“错误”过程,以便代码可以在不同的方案实现之间移植。

我尝试过“显示”,但它似乎并不完全是我想要的,因为输出时不会发出错误信号。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人如玉 2024-09-14 05:42:47

这是我们的讲师给我们的实现:

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

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)) 
屌丝范 2024-09-14 05:42:47

好吧,根据这个: http://srfi.schemers.org/srfi- 23/srfi-23.html,错误过程非常广泛可用,所以我认为您使用它是安全的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文