The Art of the Metaobject Protocol- P3

The Art of the Metaobject Protocol- P3: The work described here is synthetic in nature, bringing together techniques and insights from several branches of computer. | Introspection and Analysis 57 This lack of consistency in the order in which color-mixin and rectangle appear may be a problem for certain kinds of method definitions. For example consider a generic function with exactly two primary methods one specialized to the class color-mixin and the other to the class rectangle. When this generic function is invoked on an instance of color-rectangle the method specialized to color-mixin will be run. On the other hand when the generic function is called on an instance of color-chart the method specialized to rectangle will be run. Depending on the methods this may or may not be what is desired. In any case it is useful to have a tool which can detect this case so that the programmer can be aware of it. We say that a pair of classes Ci and C2 are in order provided that Ci appears before C2 in the class precedence list of all of their common If two classes are in order we know that pairs of methods specialized to them will always be run in that order. The predicate in-order-p tests whether a pair of classes are in order defun in-order-p cl c2 flet in-order-at-subclass-p sub let cpl class-precedence-list sub not null member c2 cdr member cl cpl or eq cl c2 every in-order-at-subclass-p intersection subclasses cl subclasses c2 The classes color-mixin and rectangle are not in order because their common subclasses color-chart and color-rectangle are not in agreement in-order-p find-class color-mixin find-class rectangle NIL On the other hand the classes standard-object and t are in order. It would be a sign of serious trouble if they weren t. in-order-p find-class standard-object find-class t T The rules of class precedence list computation are such that a class C is always in order with respect to each of its superclasses. 58 Chapter 2 Exercise Consider another scenario of multiple inheritance gone awry defclass position x y defclass cad-element position . . defclass display-element position . . The class position .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.