【发布时间】:2020-11-27 20:08:34
【问题描述】:
如果我有两个班级,一个班级parent 和一个班级child。
(defclass parent ()
...)
(defclass child (parent)
...)
我已经为初始化实例定义了 2 种不同的方法,但是孩子接受另一个参数,并调用 call-next-method
(defmethod initialize-instance :after ((instance parent) &key)
...) ; Do things
(defmethod initialize-instance :after ((instance child) &key other-arg)
... ; Do things
(call-next-method))
我得到了错误
There is no next method for the generic function
#<STANDARD-METHOD COMMON-LISP:INITIALIZE-INSTANCE (93)>
when called from method
#<STANDARD-METHOD COMMON-LISP:INITIALIZE-INSTANCE :AFTER (CHILD) {...}>
with arguments
....
Condition of type SB-PCL::NO-NEXT-METHOD-ERROR
显然,我无法使用提供的参数调用下一个方法?
【问题讨论】:
标签: common-lisp clos