I'd like to publish an other solution of Michael Kappert who just
sent me a mail. It works too quite well.
(defclass super () ((f :accessor f :initform "foo")))
(defclass sub (super) ((f :accessor f :initform "bar")))
(defmethod initialize-instance ((c super) &rest args)
(let* ((x (call-next-method))
(cpl (clos:class-precedence-list (class-of c)))
(initval))
(dolist (sc cpl)
(dolist (slot (clos:class-direct-slots sc))
(if (eq 'f (clos:slot-definition-name slot))
(push (clos:slot-definition-initform slot) initval))))
(setf (slot-value x 'f) initval)
x))
(f (make-instance 'sub))
==> ("foo" "bar")
(defclass sub1 (sub) ())
(defclass sub2 (sub1) ((f :accessor f :initform "baz")))
(f (make-instance 'sub2))
==> ("foo" "bar" "baz")
Thank you all for your help!
Marc Dzaebel