Fix issue reported by Albert Reiner, cmucl-help, 2006/10/20, and fix
another issue with uninitialized &aux variables. (defstruct (foobar (:constructor make-foobar (xxx &key (aaa nil) (bbb nil) &aux (foobar-data xxx) (aaa (or aaa (getf foobar-data :aaa) 1)) (bbb (or bbb (getf foobar-data :bbb) (1+ aaa)))))) (aaa (required-argument) :type fixnum) (bbb (required-argument) :type fixnum)) (make-foobar nil) -> #<foobar :aaa 1 :bbb 2> But CMUCL gives type errors. To fix Albert's issue, modify CREATE-BOA-CONSTRUCTOR to keep track of the &aux vars separately from the other arglist vars. Adjust CREATE-VECTOR-CONSTRUCTOR, CREATE-LIST-CONSTRUCTOR, CREATE-STRUCTURE-CONSTRUCTOR, and CREATE-FIN-CONSTRUCTOR to take an extra arg for the &aux vars. For CREATE-STRUCTURE-CONSTRUCTOR, we only put declarations for the other arglist vars. To make sure we store the right kinds of objects into the slots, we also wrap (the <type> init) for each initial value. Also CLHS 3.4.6 has an example of a boa constructor using an aux variable without an initializer. CMUCL was not handling that right. Modify CREATE-BOA-CONSTRUCTOR to change the initializer to use (or <aux> slot-default-value) to get the correct default value into the slot if the aux variable doesn't.
Loading
Please register or sign in to comment