[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader whe
From: |
Stefan Monnier |
Subject: |
bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value |
Date: |
Wed, 29 Nov 2023 10:46:52 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
>> 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))))))
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Brandon Irizarry, 2023/11/04
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Eli Zaretskii, 2023/11/11
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Stefan Monnier, 2023/11/25
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Brandon Irizarry, 2023/11/25
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Stefan Monnier, 2023/11/26
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, João Távora, 2023/11/28
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Stefan Monnier, 2023/11/29
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, João Távora, 2023/11/29
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value,
Stefan Monnier <=
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, João Távora, 2023/11/29
- bug#66938: 30.0.50 [PATCH]: Make EIEIO :accessor behave like :reader when reading a slot's value, Stefan Monnier, 2023/11/29
bug#66938: 30.0.50; Commit 6c47931a1ad4de ("Make EIEIO ':accessor' behave like ':reader' when reading (bug#66938)") breaks Eglot, Arsen Arsenović, 2023/11/28