在我的类定义中,我想根据另一个插槽的值初始化一个插槽。这是我想做的事情:
(defclass my-class ()
((slot-1 :accessor my-class-slot-1 :initarg slot-1)
(slot-2 :accessor my-class-slot-2 :initform (list slot-1))))
但是,这不会编译:
1 compiler notes:
Unknown location:
warning:
This variable is undefined:
SLOT-1
warning:
undefined variable: SLOT-1
==>
(CONS UC-2::SLOT-1 NIL)
Compilation failed.
有没有办法做到这一点?
最佳答案
使用 initialize-instance :after
记录在案 here
关于common-lisp - 基于 Common Lisp 对象系统类定义中的其他槽值初始化槽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3620249/