dear list,
i wanted to set the default-component-class of our own system subclass using :default-initargs, but it's ignored because the slot has a :initform (as opposed to setting the default value using a :default-initargs entry).
in the current ASDF setup, i need to override the slot (or the accessor method), which involves messing with internal symbols.
if ASDF used :default-initargs then i could just override that using a :default-initargs entry on my own subclass (IIUC).
https://lisptips.com/post/11728375873/initform-and-default-initargs
i'm sending it for your consideration, it's not a pressing issue on my side.
- attila PGP: 5D5F 45C7 DFCD 0A39
I don’t fully understand the issue. I followed up the reference you posted, and the follow-on reference to Chris Riesbeck’s web page, and there I see the following:
make-instance (in conjunction with initialize-instance) creates an instance of a circle as follows:
make-instance creates an empty instance. make-instance passes the instance and the other arguments to initialize-instance. initialize-instance first uses any explicit initargs that you gave to make-instance. For slots still unitialized, it then uses any default initargs that have been defined. Finally, for slots still unitialized, it uses any default initforms that have been defined.
So one difference is that default initargs take priority over initforms.
———-
This suggests that your default initargs (Apple tried to make that “unitards”!) should, in fact, shadow the initforms.
This seems to be consistent with what is in the spec here http://www.lispworks.com/documentation/HyperSpec/Body/07_a.htm
I’ll have to look at the actual code (not at my desk rn) to see what’s going on, but it does not seem to be an issue with default initargs vs. initforms
If anyone else beats me to it, that would be great.
-- Robert P. Goldman
On December 22, 2021 at 05:18:58, Attila Lendvai (attila@lendvai.name(mailto:attila@lendvai.name)) wrote:
dear list,
i wanted to set the default-component-class of our own system subclass using :default-initargs, but it's ignored because the slot has a :initform (as opposed to setting the default value using a :default-initargs entry).
in the current ASDF setup, i need to override the slot (or the accessor method), which involves messing with internal symbols.
if ASDF used :default-initargs then i could just override that using a :default-initargs entry on my own subclass (IIUC).
https://lisptips.com/post/11728375873/initform-and-default-initargs
i'm sending it for your consideration, it's not a pressing issue on my side.
- attila
PGP: 5D5F 45C7 DFCD 0A39
Yes, this works as expected for me:
(defclass foosys (asdf/system:system) () (:default-initargs :default-component-class 'foo))
(asdf/component:module-default-component-class (make-instance 'foosys)) => foo
Yes, this works as expected for me:
(defclass foosys (asdf/system:system) () (:default-initargs :default-component-class 'foo))
(asdf/component:module-default-component-class (make-instance 'foosys)) => foo
indeed. after Robert's mail i also tried this, and it worked, yet i'm seeing the error when i use :default-initargs, but not when i'm using a slot override.
it's a more convoluted issue involving our entire codebase that i'll need to investigate. sorry for the noise!
- attila
i think i know why this is happening.
i have attached a test that has the two versions that i have talked about. the slot override works, but the default-initarg doesn't.
ASDF probably calls change-class, probably from reset-system-class, which invokes reinitialize-instance directly, and somewhere here the default initargs are ignored.
but my CLOS is rusty.
is this a user bug, or an ADSF bug?
- attila
Yes, that is right. `parse-defsystem` calls `change-class`. I will set up an issue for this, and put you on the cc list.
On 22 Dec 2021, at 10:49, Attila Lendvai wrote:
i think i know why this is happening.
i have attached a test that has the two versions that i have talked about. the slot override works, but the default-initarg doesn't.
ASDF probably calls change-class, probably from reset-system-class, which invokes reinitialize-instance directly, and somewhere here the default initargs are ignored.
but my CLOS is rusty.
is this a user bug, or an ADSF bug?
- attila