GNU bug report logs - #76533
[PATCH] Make cl-proclaim and cl-declaim obsolete

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Mon, 24 Feb 2025 21:27:02 UTC

Severity: wishlist

Tags: patch

Full log


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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 76533 <at> debbugs.gnu.org, mattias.engdegard <at> gmail.com
Subject: Re: [PATCH] Make cl-proclaim and cl-declaim obsolete
Date: Tue, 25 Feb 2025 15:29:30 -0500
> However, simply removing these CL-Lib specific variables makes the
> compiled file size of eieieo-core.el (our only user of cl-declaim)
> increase by almost 20%:
>
> -rw-r--r--  1 skangas  staff  40705 Feb 24 21:31 eieio-core.elc
> -rw-r--r--  1 skangas  staff  45572 Feb 24 21:31 lisp/emacs-lisp/eieio-core.elc

It also makes it slower, yes.
The patch below removes this use of `cl-declaim` without the
corresponding performance impact.


        Stefan


diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index c3c8361b38e..db4c52d8789 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2999,6 +2999,8 @@ cl--struct-default-parent
 
 (defvar cl--struct-inline t
   "If non-nil, `cl-defstruct' will define inlinable functions.")
+(make-obsolete-variable
+ 'cl--struct-inline "use :noinline keyword instead" "31.1")
 
 ;;;###autoload
 (defmacro cl-defstruct (struct &rest descs)
@@ -3012,7 +3014,8 @@ cl-defstruct
 OPTIONS...), where each OPTION is either a single keyword
 or (KEYWORD VALUE) where KEYWORD can be one of `:conc-name',
 `:constructor', `:copier', `:predicate', `:type', `:named',
-`:initial-offset', `:print-function', `:noinline', or `:include'.
+`:initial-offset', `:print-function', `:noinline', `:include',
+or `:unsafe-accessors'.
 See Info node `(cl)Structures' for the description of the
 options.
 
@@ -3125,6 +3128,8 @@ cl-defstruct
 	       (setq named t))
 	      ((eq opt :noinline)
 	       (setq defsym 'defun) (setq cldefsym 'cl-defun))
+	      ((eq opt :unsafe-accessors)
+	       (setq safety 0))
 	      ((eq opt :initial-offset)
 	       (setq descs (nconc (make-list (car args) '(cl-skip-slot))
 				  descs)))
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index f95fd65fa5c..fe7cd33aa77 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -79,12 +79,8 @@ eieio--unbound-form
 ;; while it is being built itself.
 (defvar eieio-default-superclass nil)
 
-(progn
-  ;; Arrange for field access not to bother checking if the access is indeed
-  ;; made to an eieio--class object.
-  (eval-when-compile (cl-declaim (optimize (safety 0))))
-
 (cl-defstruct (eieio--class
+               :unsafe-accessors
                (:constructor nil)
                (:constructor eieio--class-make (name))
                (:include cl--class)
@@ -101,12 +97,6 @@ eieio-default-superclass
   options ;; storage location of tagged class option
           ; Stored outright without modifications or stripping
   )
-  ;; Set it back to the default value.  NOTE: Using the default
-  ;; `safety' value does NOT give the default
-  ;; `byte-compile-delete-errors' value.  Therefore limit this (and
-  ;; the above `cl-declaim') to compile time so that we don't affect
-  ;; code which only loads this library.
-  (eval-when-compile (cl-declaim (optimize (safety 1)))))
 
 
 (eval-and-compile





This bug report was last modified 132 days ago.

Previous Next


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