灯下 登录
计算机科学 / SICP / 5.5.7 Interfacing Compiled Code to the Evaluator

Exercise 5.49 · 习题

Exercise 5.49: As an alternative to using the

explicit-control evaluator’s read-eval-print loop, design a register machine

that performs a read-compile-execute-print loop. That is, the machine should

run a loop that reads an expression, compiles it, assembles and executes the

resulting code, and prints the result. This is easy to run in our simulated

setup, since we can arrange to call the procedures compile and

assemble as “register-machine operations.”

练习 5.49:作为使用显式控制求值器读入-求值-打印循环的替代方案,设计一台执行"读入-编译-执行-打印"循环的寄存器机器。即该机器运行一个循环:读入一个表达式,将其编译,汇编并执行所得代码,然后打印结果。在我们的模拟环境中,这很容易实现,因为可以将过程 compile 和 assemble 安排为"寄存器机器操作"来调用。