是否有一种变通方法,可以像LET*
中那样按顺序处理结构主体插槽绑定,以便以后的插槽可见先前的插槽分配?
例如,在下面的示例中,我希望c
可见d
。
(defstruct (my-struct (:constructor cons-struct (a b)))
(c (* a b))
(d c))
我怎么能得到这种效果?
答案 0 :(得分:6)
您已经使用了boa constructor。您可以使用其boa lambda list按顺序执行操作:
(defstruct (my-struct (:constructor cons-struct (a b
&aux
(c (* a b))
(d c))))
c
d)