effective-slot-class generic
effective-slot-direct-slot generic
effective-slot-initializer generic
+ find-class-initializer generic
find-slot-initargs generic
find-slot-initializer generic
ichain class
finalize-sod-class
sod-class
sod-class [:around]
+find-class-initializer
+ effective-slot sod-class
find-slot-initargs
sod-class sod-slot
find-slot-initializer
{find-slot-initializer @<class> @<slot> @> @<init-or-nil>}
\end{describe}
+\begin{describe}{gf}
+ {find-class-initializer @<slot> @<class> @> @<init-or-nil>}
+\end{describe}
+
\begin{describe}{gf}{find-slot-initargs @<class> @<slot> @> @<list>}
\end{describe}
:initializer (find-slot-initializer class slot)
:initargs (find-slot-initargs class slot)))
+(defmethod find-class-initializer ((slot effective-slot) (class sod-class))
+ (let ((dslot (effective-slot-direct-slot slot)))
+ (or (some (lambda (super)
+ (find dslot (sod-class-class-initializers super)
+ :key #'sod-initializer-slot))
+ (sod-class-precedence-list class))
+ (effective-slot-initializer slot))))
+
;;;--------------------------------------------------------------------------
;;; Special-purpose slot objects.
SLOT is a direct slot defined on CLASS or one of its superclasses.
(Metaclass initializers are handled using a different mechanism.)"))
+(export 'find-class-initializer)
+(defgeneric find-class-initializer (slot class)
+ (:documentation
+ "Return an initializer value (any printable value) for a class slot SLOT.
+
+ The initializer might come either from the SLOT's defining class (which it
+ already knows), or from the instance CLASS, of which the defining class is
+ be (a superclass of) the metaclass.
+
+ This is used as part of `has-class-initializer-p' and the default output
+ hook for `effective-slot': if you override both of those then you don't
+ need to override this too."))
+
;;;--------------------------------------------------------------------------
;;; Instance layout.
(vtable-name class chain-head)
(sod-class-nickname chain-tail))))))
-(defgeneric find-class-initializer (slot class)
- (:method ((slot effective-slot) (class sod-class))
- (let ((dslot (effective-slot-direct-slot slot)))
- (or (some (lambda (super)
- (find dslot (sod-class-class-initializers super)
- :key #'sod-initializer-slot))
- (sod-class-precedence-list class))
- (effective-slot-initializer slot)))))
-
(defgeneric output-class-initializer (slot instance stream)
(:method ((slot sod-class-effective-slot) (instance sod-class) stream)
(let ((func (effective-slot-initializer-function slot))