灯下 登录
计算机科学 / SICP / 5.5.6 Lexical Addressing

Exercise 5.39 · 习题

Exercise 5.39: Write a procedure

lexical-address-lookup that implements the new lookup operation. It

should take two arguments—a lexical address and a run-time environment—and

return the value of the variable stored at the specified lexical address.

Lexical-address-lookup should signal an error if the value of the

variable is the symbol *unassigned*. Also write a procedure

lexical-address-set! that implements the operation that changes the

value of the variable at a specified lexical address.

练习 5.39:编写过程 lexical-address-lookup,实现新的查找操作。它接受两个参数——词法地址 (lexical address) 和运行时环境——并返回存储在指定词法地址处的变量的值。若该变量的值是符号 *unassigned*,lexical-address-lookup 应发出错误信号。另外编写过程 lexical-address-set!,实现修改指定词法地址处变量值的操作。