让 SICP 在 Racket 上运行:练习 4.48,无法让 load() 工作

发布于 2025-01-12 09:34:25 字数 1633 浏览 0 评论 0原文

我正在尝试解决 SICP 的练习 4.48。我试图让加载机制运行,即加载 ch4-mceval.scm (期望所有定义都可用),但我似乎没有得到正确的语法。

我尝试过

#lang Planet neil/sicp#lang sicp,尝试过(load "ch4-mceval.scm")(#%require "ch4-mceval.scm"),全部失败。

我有一个笨拙的解决方法,我基本上将两个文件合并为一个,但我发现这真的很难看。

任何帮助将不胜感激。

ch4-ambeval.rkt 开始,尝试加载 ch4-mceval.rkt

#lang planet neil/sicp ; added 07 MAR 2022
;;;;AMB EVALUATOR FROM SECTION 4.3 OF
;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS

;;;;Matches code in ch4.scm.
;;;; To run the sample programs and exercises, code below also includes
;;;; -- enlarged primitive-procedures list
;;;; -- support for Let (as noted in footnote 56, p.428)

;;;;This file can be loaded into Scheme as a whole.
;;;;**NOTE**This file loads the metacircular evaluator of
;;;;  sections 4.1.1-4.1.4, since it uses the expression representation,
;;;;  environment representation, etc.
;;;;  You may need to change the (load ...) expression to work in your
;;;;  version of Scheme.
;;;;**WARNING: Don't load mceval twice (or you'll lose the primitives
;;;;  interface, due to renamings of apply).

;;;;Then you can initialize and start the evaluator by evaluating
;;;; the two lines at the end of the file ch4-mceval.scm
;;;; (setting up the global environment and starting the driver loop).
;;;;In the driver loop, do
;(define (require p)
;  (if (not p) (amb)))


;;**implementation-dependent loading of evaluator file
;;Note: It is loaded first so that the section 4.2 definition
;; of eval overrides the definition from 4.1.1
(load "ch4-mceval.scm")

I'm trying to solve excercise 4.48 from SICP. I'm trying to get the loading mechanism to run, i.e. load ch4-mceval.scm (with the expectation that all the definitions are available) but I don't seem to get the syntax right.

I've tried

#lang planet neil/sicp and #lang sicp, tried (load "ch4-mceval.scm") and (#%require "ch4-mceval.scm"), all unsuccesffuly.

I have a kludgy workaround where I basically merged the two files into one, but I find that really ugly.

Any help would be greatly appreciated.

start of ch4-ambeval.rkt, which tries to load ch4-mceval.rkt

#lang planet neil/sicp ; added 07 MAR 2022
;;;;AMB EVALUATOR FROM SECTION 4.3 OF
;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS

;;;;Matches code in ch4.scm.
;;;; To run the sample programs and exercises, code below also includes
;;;; -- enlarged primitive-procedures list
;;;; -- support for Let (as noted in footnote 56, p.428)

;;;;This file can be loaded into Scheme as a whole.
;;;;**NOTE**This file loads the metacircular evaluator of
;;;;  sections 4.1.1-4.1.4, since it uses the expression representation,
;;;;  environment representation, etc.
;;;;  You may need to change the (load ...) expression to work in your
;;;;  version of Scheme.
;;;;**WARNING: Don't load mceval twice (or you'll lose the primitives
;;;;  interface, due to renamings of apply).

;;;;Then you can initialize and start the evaluator by evaluating
;;;; the two lines at the end of the file ch4-mceval.scm
;;;; (setting up the global environment and starting the driver loop).
;;;;In the driver loop, do
;(define (require p)
;  (if (not p) (amb)))


;;**implementation-dependent loading of evaluator file
;;Note: It is loaded first so that the section 4.2 definition
;; of eval overrides the definition from 4.1.1
(load "ch4-mceval.scm")

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

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

发布评论

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

评论(1

北方的巷 2025-01-19 09:34:25

我在 DrRacket 中尝试了 mceval.scmload 似乎没有任何问题。

PS我没有planet neil/sicp,因为Racket(>8.0)已经内置了sicp语言。

输入图片此处描述

I tried mceval.scm in DrRacket, it seems nothing wrong with load.

P.s I did not planet neil/sicp, because Racket (>8.0) has already a built-in sicp language.

enter image description here

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