[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EIEIO accessing class slots
From: |
Stefan Monnier |
Subject: |
Re: EIEIO accessing class slots |
Date: |
Fri, 11 Jun 2021 09:45:17 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> (oref-default 'moirai-dired-side :display-alist)
>> instead of
>> (oref-default 'moirai-dired-side 'display-alist)
>> ?
> because it don't work.
Oh, that's right `oref` and `oref-default` are macros, which quote their
second arg, contrary to `slot-value` which is a function and is the
more "normal" accessor.
But there's no `slot-value-default`, indeed.
[ Side note: Using the slot name, as in (oref-default 'moirai-dired-side
display-alist), is more efficient than using the initarg name, as in
(oref-default 'moirai-dired-side :display-alist), which is deprecated. ]
>> Also, why do you need to do (oref-default 'moirai-dired-side
>> :display-alist), what do you expect it to return?
> The default value inherited by some of the objects.
But this is a lie :-(
The real semantics of the "default value" is a lot more murky.
It works like you expect only when the default value is defined as
a constant.
>> If you expect it to return the ((moirai-dired-p) ...)
>> you specified in the `defclass`, then why not do:
>> (defvar foo-bar '((moirai-dired-p) ...))
>> so you can get this value without having to ask the class?
> Is that terrible to ask to the class ?
To the extent that it doesn't exist in CLOS, then I think it's better to
avoid using this functionality ;-)
Stefan