GNU bug report logs -
#49291
[akater] [PATCH] lisp/emacs-lisp/eieio.el (initialize-instance): Fix initform
Previous Next
Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date: Wed, 30 Jun 2021 13:33:02 UTC
Severity: normal
Tags: patch
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 49291 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier [2021-06-30 09:32:32] wrote:
> This is not what happens in eieio. Rather, initform is evaluated even
> when initarg is present.
Good catch, thanks.
> @@ -756,13 +756,15 @@ defclass eieio-default-superclass nil
> (dotimes (i (length slots))
> ;; For each slot, see if we need to evaluate it.
> (let* ((slot (aref slots i))
> + (slot-name (eieio-slot-descriptor-name slot))
> (initform (cl--slot-descriptor-initform slot)))
> ;; Those slots whose initform is constant already have the right
> ;; value set in the default-object.
> - (unless (macroexp-const-p initform)
> + (unless (or (rassq slot-name
> + (eieio--class-initarg-tuples this-class))
> + (macroexp-const-p initform))
> ;; FIXME: We should be able to just do (aset this (+ i <cst>) dflt)!
> - (eieio-oset this (cl--slot-descriptor-name slot)
> - (eval initform t))))))
> + (eieio-oset this slot-name (eval initform t))))))
> ;; Shared initialize will parse our slots for us.
> (shared-initialize this slots))
Hmm... if I read this correctly, you prevents the (eval initform t) for
all slots that were declared with `:initarg <KEYWORD>`, whereas AFAIK the
right semantic is to prevent the (eval initform t) in the case where the
corresponding <KEYWORD> was passed to `make-instance`.
So we should pay attention to `slots` (the arg, not the local var) to
decide whether to skip (eval initform t).
Stefan
This bug report was last modified 3 years and 362 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.