common lisp - Override :INITFORM of the class slot in subclass -
i need generalize default slot value in subclass.
example:
(defclass class-a () ((slot-1 :initarg :slot-1 :initform #'identity) <...> other-slots<...>)) its subclass is
(defclass class-b (class-a) ((slot-2 :initarg :slot-2 :initform 0))) but #'identity not enough default value, more general
(lambda (&rest x) x) will suit better expect multiple arguments (i think doesn't contradict liskov principle). best way override :initform class-b?
- i can add
initialize-instance :afterclass-b, see ifslot-1set#'identity, override it. - what happens if reintroduce
slot-1inclass-b? want avoid have repeat slot information it.
what happens if reintroduce slot-1 in class-b?
it works.
i want avoid have repeat slot information it.
no. difference.
Comments
Post a Comment