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?

  1. i can add initialize-instance :after class-b , see if slot-1 set #'identity , override it.
  2. what happens if reintroduce slot-1 in class-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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -