Plaster
New
List
Login
common-lisp
default
anonymous
2022.02.16 19:16:10
;;; What I'm trying to do: specify a form in initform that depends on ;;; a given initarg (or even several initargs). (defclass test-class () ((my-slot-that-depends-on-initarg :initargs :depend-slot :initform (do-something-with-initarg depend-slot) ;; Doesn't work (obviously) ;; What to do here to specify initform ;; such that it depends upon depend-slot? ))) ;;; Example, but with initialize-instance 'after' method that does work. ;;; Is it possible to use a keyword while still in the slot specification to do this? ;;; Or is this the only way? (defclass test-class-with-initialize-method () ((my-slot-that-depends-on-initarg))) (defmethod initialize-instance :after ((instance test-class-with-initialize-method) &key (depend-slot nil)) (setf (slot-value instance 'my-slot-that-depends-on-initarg) (do-something-with-initarg depend-slot)))
Raw
Annotate
Repaste
Edit