GNU bug report logs - #63282
30.0.50; Phase out `cl-old-struct-compat-mode`

Previous Next

Package: emacs;

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

Date: Thu, 4 May 2023 17:52:01 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63282 in the body.
You can then email your comments to 63282 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#63282; Package emacs. (Thu, 04 May 2023 17:52:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 04 May 2023 17:52:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Phase out `cl-old-struct-compat-mode`
Date: Thu, 04 May 2023 13:51:09 -0400
[Message part 1 (text/plain, inline)]
Package: Emacs
Version: 30.0.50


`cl-old-struct-compat-mode` is a hideous hack I introduced back
in Emacs-26 when we switched CL structs from using plain vectors to
using the new `record` type.  It provides some limited amount
of backward compatibility with code using `cl-defstruct` that was
compiled with 23<Emacs<26, at the cost of installing an advice on
`type-of` which tends to impact the performance of most
method dispatches in a non-trivial way.

I honestly don't know how much it's still used, so I propose the patch
below which declares that compatibility functionality as being obsolete,
and additionally emits a warning message *at run time* when it's used.

We usually keep our obsolescence message to compile time, but since this
is meant to detect the use of old `.elc` files, the relevant
compile-time is long past :-(

I also count on the fact that we still have a fair bit of time until
Emacs-30 is released, to discover that the run-time warning is too
annoying.

Any objection (beside the need to add a etc/NEWS message, obviously)?


        Stefan


[old-struct-compact.patch (text/x-diff, inline)]
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 7fee780a735..28d42cb69ab 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -560,6 +560,7 @@ cl-old-struct-compat-mode
     (advice-add 'type-of :around #'cl--old-struct-type-of))
    (t
     (advice-remove 'type-of #'cl--old-struct-type-of))))
+(make-obsolete 'cl-old-struct-compat-mode nil "30.1")
 
 (defun cl-constantly (value)
   "Return a function that takes any number of arguments, but returns VALUE."
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
index 9445093f143..da2780503b8 100644
--- a/lisp/emacs-lisp/cl-preloaded.el
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -158,7 +158,9 @@ cl-struct-define
   (cl-check-type name (satisfies cl--struct-name-p))
   (unless type
     ;; Legacy defstruct, using tagged vectors.  Enable backward compatibility.
-    (cl-old-struct-compat-mode 1))
+    (with-suppressed-warnings ((obsolete cl-old-struct-compat-mode))
+      (message "cl-old-struct-compat-mode is obsolete!")
+      (cl-old-struct-compat-mode 1)))
   (if (eq type 'record)
       ;; Defstruct using record objects.
       (setq type nil))

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Tue, 05 Sep 2023 16:58:02 GMT) Full text and rfc822 format available.

Notification sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
bug acknowledged by developer. (Tue, 05 Sep 2023 16:58:02 GMT) Full text and rfc822 format available.

Message #10 received at 63282-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 63282-done <at> debbugs.gnu.org
Subject: Re: bug#63282: 30.0.50; Phase out `cl-old-struct-compat-mode`
Date: Tue, 05 Sep 2023 12:57:18 -0400
Pushed, thanks


        Stefan





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Oct 2023 11:24:40 GMT) Full text and rfc822 format available.

This bug report was last modified 204 days ago.

Previous Next


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