4

インスタンスのメソッドが継承するのと同じ方法で、クラスの祖先に基づいて継承するクラス オブジェクトのメソッドを定義したいと思います。これを行う方法はありますか?

機能していないのは次のとおりです。 -eqlメソッドの特殊化。次の例を検討してください。

(defclass animal ()())
(defclass bird (animal)())
(defclass woodpecker (bird)())

(defmethod wings-p ((animal-class (eql (find-class 'animal)))) nil)
(defmethod wings-p ((bird-class   (eql (find-class 'bird))))   t)

を呼び出すと が(wings-p (find-class 'woodpecker))生成され、そのno-method-error理由がわかります - classwoodpeckerは明らかeqlにどのメソッドの専門家にも当てはまりません。

bird「メソッド」を onに定義して、 onanimalを呼び出すとが返されるようにしたいと思います。wings-p(find-class woodpecker)wings-pt

これはほぼすべての OO システムの標準機能のように感じますが、CLOS でそれを行う方法を思い出せません。

4

1 に答える 1