灯下 登录
计算机科学 / SICP / 2.4.3 Data-Directed Programming and Additivity

Exercise 2.76 · 习题

Exercise 2.76: As a large system with generic

operations evolves, new types of data objects or new operations may be needed.

For each of the three strategies—generic operations with explicit dispatch,

data-directed style, and message-passing-style—describe the changes that

must be made to a system in order to add new types or new operations. Which

organization would be most appropriate for a system in which new types must

often be added? Which would be most appropriate for a system in which new

operations must often be added?

练习 2.76:随着一个具有通用操作的大型系统不断演化,可能需要新的数据对象类型或新的操作。对于以下三种策略——带显式分派的通用操作、数据导向风格和消息传递风格——各描述为向系统添加新类型或新操作所必须作出的改动。对于一个经常需要添加新类型的系统,哪种组织方式最为合适?对于一个经常需要添加新操作的系统,哪种组织方式最为合适?