next up previous
Next: 14.5 Sendの実現 Up: 14 オブジェクト指向機能の実現 Previous: 14.3 Instance生成

14.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月7日