所以我有课
(defclass foo ()
((a :initarg :a :accessor a)
(b :initarg :b :accessor b)))
(defclass bar (foo)
((c :initarg :c)))
和一个构造函数
(defun make-foo (a b)
(make-instance 'foo :a a :b b))
有没有一种简单的方法来定义一个函数,该函数接受一个现有的FOO
并产生一个定义BAR
了额外插槽的C
函数?即无需列出所有插槽:
(defun make-bar-from-foo (existing-foo c)
(make-instance 'bar :a (a existing-foo) :b (b existing-foo) :c c))