Common Lisp中我注意到,我可以这样写:我可以参考defstruct中的其他插槽吗?
(defun foo (&key (a 1) (b 2) (c (+ a b))) (print (+ a b c)))
当我打电话(foo)
,打印6
。所以参数c
可以参考为a
和b
设置的值。但我似乎无法找到与defstruct
类似的方法。例如:
CL-USER> (defstruct thing a b c)
THING
CL-USER> (setq q (make-thing :a 1 :b 2 :c (+ a b)))
; Evaluation aborted
CL-USER> (setq q (make-thing :a 1 :b 2 :c (+ :a :b)))
; Evaluation aborted
有没有办法做到这一点?
啊,这好像是我所希望的......谢谢! – casper 2009-02-12 22:39:11