GNU bug report logs -
#66938
30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value
Previous Next
Reported by: Brandon Irizarry <brandon.irizarry <at> gmail.com>
Date: Sat, 4 Nov 2023 22:04:01 UTC
Severity: normal
Tags: patch
Found in version 30.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #55 received at 66938 <at> debbugs.gnu.org (full text, mbox):
>> I think this works nowadays (the expression is not evaluated in the
>> right context (it's evaluated in the empty context), but AFAICT it's
>> evaluated at the right time):
> No, I think there's something off. In CLOS:
[...]
> *** Welcome to IELM *** Type (describe-mode) or press C-h m for help.
> ELISP> (defclass foo () ((bar :initarg :bar :initform (error "BAR is
> required!"))))
> *** Eval error *** BAR is required!
> ELISP>
Duh! Still victim from the original EIEIO design where the `:initform`s
were executed at `defclass` time and then stored in a kind of
"prototype" object (presumably to speed up the creation of objects).
I pushed the patch below to fix this problem. I can't believe this has
lingered since my Emacs-25 "rework" where I went through the trouble to
better align the semantics with that of CLOS.
Stefan
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index a394156c93a..37c5ebdb6da 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -951,7 +951,10 @@ eieio-set-defaults
(let ((slots (eieio--class-slots (eieio--object-class obj))))
(dotimes (i (length slots))
(let* ((name (cl--slot-descriptor-name (aref slots i)))
- (df (eieio-oref-default obj name)))
+ ;; If the `:initform` signals an error, just skip it,
+ ;; since the error is intended to be signal'ed from
+ ;; `initialize-instance` rather than at the time of `defclass`.
+ (df (ignore-errors (eieio-oref-default obj name))))
(if (or df set-all)
(eieio-oset obj name df))))))
This bug report was last modified 1 year and 174 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.