unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#63282: 30.0.50; Phase out `cl-old-struct-compat-mode`
@ 2023-05-04 17:51 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-05 16:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-05-04 17:51 UTC (permalink / raw)
  To: 63282

[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]

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



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: old-struct-compact.patch --]
[-- Type: text/x-diff, Size: 1180 bytes --]

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))

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#63282: 30.0.50; Phase out `cl-old-struct-compat-mode`
  2023-05-04 17:51 bug#63282: 30.0.50; Phase out `cl-old-struct-compat-mode` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-05 16:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-05 16:57 UTC (permalink / raw)
  To: 63282-done

Pushed, thanks


        Stefan






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-05 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 17:51 bug#63282: 30.0.50; Phase out `cl-old-struct-compat-mode` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-05 16:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).