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

From: Stefan Monnier <[email-masked]>
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.