灯下 登录
计算机科学 / SICP / 2.5.2 Combining Data of Different Types

Exercise 2.84 · 习题

Exercise 2.84: Using the raise operation

of Exercise 2.83, modify the apply-generic procedure so that it

coerces its arguments to have the same type by the method of successive

raising, as discussed in this section. You will need to devise a way to test

which of two types is higher in the tower. Do this in a manner that is

“compatible” with the rest of the system and will not lead to problems in

adding new levels to the tower.

练习 2.84:利用练习 2.83 中的 raise 操作,修改 apply-generic 过程,使其通过逐步提升的方法将参数强制转换为相同类型,如本节所述。你需要设计一种方法来检验两种类型中哪种在塔中处于更高的位置。这种方法应当与系统的其余部分"兼容",并且在向塔中添加新层次时不会引发问题。