The Art of the Metaobject Protocol- P10

The Art of the Metaobject Protocol- P10: The work described here is synthetic in nature, bringing together techniques and insights from several branches of computer. | 272 Appendix C can be changed to j defun ensure-class . . apply if eq metaclass find-class standard-class make-instance-standard-class make-instance metaclass . . Mostly what make-instance-standard-class does is to initialize slots from initialization arguments this can be accomplished with inline calls to the metaobject slot accessors. Other initialization is performed by a class-specific after-method on initialize-instance and by f inalize-inheritance. We can avoid unnecessary code duplication by moving most of the code from the standard methods into independently callable functions. . the standard method for finalize-inheritance a defmethod finalize-inheritance body class standard-class can be split into a minimal method that calls a normal function named std-f inalize-inheritance that does all the actual work defmethod finalize-inheritance class standard-class std-finalize-inheritance class defun std-finalize-inheritance class body This allows the callers of the generic function the option of directly invoking the standard method in cases when it is known that only the standard method would be applicable. For example the call finalize-inheritance class can be rewritten as funcall if eq class-of class find-class standard-class std-finalize-inheritance finalize-inheritance class because it is a sure bet that instances of standard-class will be finalized in the regular way. Living with Circularity 273 Since all classes during startup are instances of standard-class the full method lookup mechanism is bypassed during startup. But when an instance of a specialized subclass of standard-class comes along later the real method lookup mechanism for f inalize-inheritance will be properly activated. The bulk of the generic function calls are to the metaobject slot accessors . classslots . There is no particular reason in Closette why these accessors need to be generic functions at all so we have rewritten them as regular functions. This leaves only about a dozen .

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.