GNU bug report logs - #77612
[PATCH] (eieio-backward-compatibility): Change default to new `warn` value

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Mon, 7 Apr 2025 17:31:01 UTC

Severity: normal

Tags: patch

Full log


Message #8 received at 77612 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 77612 <at> debbugs.gnu.org
Cc: "Eric M. Ludlam" <zappo <at> gnu.org>
Subject: Re: bug#77612: [PATCH] (eieio-backward-compatibility): Change
 default to new `warn` value
Date: Mon, 07 Apr 2025 18:36:19 -0400
> `eieio-backward-compatibility` controls compatibility with
> features declared obsolete since Emacs-25.  I'm not sure
> we're ready to remove support for those features (i.e. to set
> `eieio-backward-compatibility` to nil), so instead I suggest
> to make uses of those features emit warnings not only at
> compile-time but also at run-time.

I forgot to add the same treatment for the (ab)use of initargs as slot
names (also deprecated since Emacs-25), so I'd suggest adding the patch
below to the previous one.


        Stefan


diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 7d0fd643056..d608517e671 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -913,12 +913,15 @@
   (let* ((fsi (gethash slot (cl--class-index-table class))))
     (if (integerp fsi)
         fsi
+      (when eieio-backward-compatibility
       (let ((fn (eieio--initarg-to-attribute class slot)))
-	(if fn
+	  (when fn
+            (when (eq eieio-backward-compatibility 'warn)
+              (message "Accessing slot `%S' via obsolete initarg name `%S'"
+                       fn slot))
             ;; Accessing a slot via its :initarg is accepted by EIEIO
             ;; (but not CLOS) but is a bad idea (for one: it's slower).
-            (eieio--slot-name-index class fn)
-          nil)))))
+            (eieio--slot-name-index class fn)))))))
 
 (defun eieio--class-slot-name-index (class slot)
   "In CLASS find the index of the named SLOT.






This bug report was last modified 57 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.