将 r5rs 文件包含到球拍中的另一个文件中
我的一门课程是使用 DrRacket 来完成 SICP 的某些部分。我们正在开发元圆求值器,我有一个 R5RS 代码文件(set-car!
和 set-cdr!
),我需要在工作中使用它。因为 R5RS 文件大约有 500 行,所以我更愿意将其保存在单独的缓冲区中。如何将其包含到我的应答缓冲区的定义中?看起来 racket/include
需要 #langracket
,但 set-car!
和 set-cdr!
不需要用那种语言。
One of my courses is using DrRacket for some sections of SICP. We're working on the metacircular evaluator and I have an R5RS code file (set-car!
and set-cdr!
) which I need to use with my work. Because the R5RS file is roughly 500 lines, I'd prefer to keep it in a separate buffer. How can I include it into my answer buffer's defintions? It appears racket/include
requires #lang racket
, but set-car!
and set-cdr!
are not in that language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以执行以下操作:
在#lang r5rs中编写模块,并在 lang 行后添加以下内容:
将答案缓冲区也放在#lang r5rs中>,并使用 #%require 获取其定义:
例如,如果我有一个f1.ss 包含以下内容:
以及 f2.ss 包含以下内容:
然后,如果我运行 f2.ss,它会执行以下操作:显示 916 及其交互缓冲区的适当内容将了解f1.ss中编写的所有定义。
这使用特定于 Racket 的低级模块导入 文档。祝你好运!
You can do the following:
Write the module in #lang r5rs, and add the following after the lang line:
Have your answer buffer also in #lang r5rs, and use #%require to pull in its definitions:
For example, if I have an f1.ss with the following content:
and an f2.ss with the following content:
then if I run f2.ss, it does the appropriate thing in displaying 916, and its Interactions buffer will know about all the definitions written in f1.ss.
This uses the Racket-specfic low-level module importing stuff mentioned in the documentation. Good luck!