让 SICP 在 Racket 上运行:练习 4.48,无法让 load() 工作
我正在尝试解决 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 DrRacket 中尝试了 mceval.scm,
load
似乎没有任何问题。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.