Subject: Re: bug#19620: 25.0.50; Eieio constructor behaviour changed and broke pcache.el

From: Stefan Monnier <[email-masked]>
Date: Sat, 17 Jan 2015 09:43:18 -0500

> (defmethod constructor :static ((x testing) newname &rest args)
>   (message "Constructor")
>   (call-next-method))

Indeed, in Emacs-25, EIEIO's object names have been mostly dropped
(with some backward compatibility).  In this case, the backward
compatibility was broken.

Hmm... let me see if we can try to better preserve the backward
compatibility here.  OK, I installed the patch below which should help.

Note that this `newname' argument won't be provided in Emacs-25 if you
use `make-instance', so you should try and change your code to use
eieio-named objects instead, if you need your objects to have a name.

        Stefan

--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -276,12 +276,6 @@ and reference them using the function `class-option'."
           `(defun ,name (&rest slots)
              ,(format "Create a new object with name NAME of class type %S."
                       name)
-             (if (and slots
-                      (let ((x (car slots)))
-                        (or (stringp x) (null x))))
-                 (funcall (if eieio-backward-compatibility #'ignore #'message)
-                          "Obsolete name %S passed to %S constructor"
-                          (pop slots) ',name))
              (apply #'eieio-constructor ',name slots))))))

@@ -656,7 +650,14 @@ SLOTS are the initialization slots used by `shared-initialize'.
 This static method is called when an object is constructed.
 It allocates the vector used to represent an EIEIO object, and then
 calls `shared-initialize' on that object."
-  (let* ((new-object (copy-sequence (eieio--class-default-object-cache (eieio--class-v class)))))
+  (let* ((new-object (copy-sequence (eieio--class-default-object-cache
+                                     (eieio--class-v class)))))
+    (if (and slots
+             (let ((x (car slots)))
+               (or (stringp x) (null x))))
+        (funcall (if eieio-backward-compatibility #'ignore #'message)
+                 "Obsolete name %S passed to %S constructor"
+                 (pop slots) class))
     ;; Call the initialize method on the new object with the slots
     ;; that were passed down to us.
     (initialize-instance new-object slots)