next up previous
Next: 9.5 Sendの実現 Up: 9 オブジェクト指向言語の実現 Previous: 9.3 Instance生成

9.4 メソッドの探索

インスタンスにメッセージが送られて メソッドを探す手続きは以下のように, そのクラスに登録されているメソッドを探し, なければ,その親クラスのメソッドを探すように 実現してあります.

(defun find-method (function class-name)
  (let ((class (get-class class-name)))
    (cond
     ((gethash function
               (class-functions class)))
     (t (find-method-in-parent
         function (class-parent class))))))
(defun find-method-in-parent (function parent)
  (if parent (find-method function parent)))


generated through LaTeX2HTML. M.Inaba 平成18年5月6日