diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2025-02-14 22:46:07 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2025-02-14 22:46:07 +0100 |
commit | f05ce9e6bbe7202060580c122e033f5e4ac98e90 (patch) | |
tree | 19e2a7aef83f1fdfd834e65bcabc2668b5a54b51 /lisp/emacs-lisp/cl-extra.el | |
parent | ac9cf20919c46169a2e3aaa2b75ccb37dd5b5ff1 (diff) | |
download | emacs-f05ce9e6bbe7202060580c122e033f5e4ac98e90.tar.gz emacs-f05ce9e6bbe7202060580c122e033f5e4ac98e90.tar.bz2 emacs-f05ce9e6bbe7202060580c122e033f5e4ac98e90.zip |
Inline important-return-value declarations in cl-lib.el
These declarations are now properly added to 'cl-lib.el' itself, or to
'cl-loaddefs.el'. This means that they will now correctly show up
immediately when loading 'cl-lib.el', instead of only after 'cl-macs.el'
is pulled in by an autoload. C.f. Bug#76247.
I did not considered worth reproducing everywhere the list saying which
functions among the below belong to these two categories:
1. Functions that are side-effect-free except for the behavior of
functions passed as argument.
2. Functions that mutate and return a list.
AFAIU, this is not actionable with our current byte-compiler, i.e. we
can't add any extra declarations based on it. However, if the list
should be needed at some point, for example due to improvements in the
compiler, this commit will be where to find it. In the worst case, and
with more work, it's also deducible from the source code itself.
* lisp/emacs-lisp/cl-macs.el: Move important-return-value declarations
from here...
* lisp/emacs-lisp/cl-extra.el (cl-map, cl-maplist, cl-mapcan)
(cl-mapcon, cl-some, cl-every, cl-notany, cl-notevery, cl-nreconc):
* lisp/emacs-lisp/cl-lib.el (cl-mapcar, cl-adjoin, cl-subst):
* lisp/emacs-lisp/cl-seq.el (cl-reduce, cl-remove, cl-remove-if)
(cl-remove-if-not, cl-delete, cl-delete-if, cl-delete-if-not)
(cl-remove-duplicates, cl-delete-duplicates, cl-substitute)
(cl-substitute-if, cl-substitute-if-not, cl-nsubstitute)
(cl-nsubstitute-if, cl-nsubstitute-if-not, cl-find, cl-find-if)
(cl-find-if-not, cl-position, cl-position-if, cl-position-if-not)
(cl-count, cl-count-if, cl-count-if-not, cl-mismatch, cl-search)
(cl-sort, cl-stable-sort, cl-merge, cl-member, cl-member-if)
(cl-member-if-not, cl-assoc, cl-assoc-if, cl-assoc-if-not, cl-rassoc)
(cl-rassoc-if, cl-rassoc-if-not, cl-union, cl-nunion, cl-intersection)
(cl-nintersection, cl-set-difference, cl-nset-difference)
(cl-set-exclusive-or, cl-nset-exclusive-or, cl-subsetp, cl-subst-if)
(cl-subst-if-not, cl-nsubst, cl-nsubst-if, cl-nsubst-if-not, cl-sublis)
(cl-nsublis, cl-tree-equal): ...to have them inline here.
Diffstat (limited to 'lisp/emacs-lisp/cl-extra.el')
-rw-r--r-- | lisp/emacs-lisp/cl-extra.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index 7732a848d3b..62e12217e0d 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -131,6 +131,7 @@ strings case-insensitively." "Map a FUNCTION across one or more SEQUENCEs, returning a sequence. TYPE is the sequence type to return. \n(fn TYPE FUNCTION SEQUENCE...)" + (declare (important-return-value t)) (let ((cl-res (apply #'cl-mapcar cl-func cl-seq cl-rest))) (and cl-type (cl-coerce cl-res cl-type)))) @@ -140,6 +141,7 @@ TYPE is the sequence type to return. Like `cl-mapcar', except applies to lists and their cdr's rather than to the elements themselves. \n(fn FUNCTION LIST...)" + (declare (important-return-value t)) (if cl-rest (let ((cl-res nil) (cl-args (cons cl-list (copy-sequence cl-rest))) @@ -189,6 +191,7 @@ the elements themselves. (defun cl-mapcan (cl-func cl-seq &rest cl-rest) "Like `cl-mapcar', but nconc's together the values returned by the function. \n(fn FUNCTION SEQUENCE...)" + (declare (important-return-value t)) (if cl-rest (apply #'nconc (apply #'cl-mapcar cl-func cl-seq cl-rest)) (mapcan cl-func cl-seq))) @@ -197,6 +200,7 @@ the elements themselves. (defun cl-mapcon (cl-func cl-list &rest cl-rest) "Like `cl-maplist', but nconc's together the values returned by the function. \n(fn FUNCTION LIST...)" + (declare (important-return-value t)) (apply #'nconc (apply #'cl-maplist cl-func cl-list cl-rest))) ;;;###autoload @@ -207,6 +211,7 @@ same as the first return value of PREDICATE where PREDICATE has a non-nil value. \n(fn PREDICATE SEQ...)" + (declare (important-return-value t)) (if (or cl-rest (nlistp cl-seq)) (catch 'cl-some (apply #'cl-map nil @@ -222,6 +227,7 @@ non-nil value. (defun cl-every (cl-pred cl-seq &rest cl-rest) "Return true if PREDICATE is true of every element of SEQ or SEQs. \n(fn PREDICATE SEQ...)" + (declare (important-return-value t)) (if (or cl-rest (nlistp cl-seq)) (catch 'cl-every (apply #'cl-map nil @@ -236,12 +242,14 @@ non-nil value. (defun cl-notany (cl-pred cl-seq &rest cl-rest) "Return true if PREDICATE is false of every element of SEQ or SEQs. \n(fn PREDICATE SEQ...)" + (declare (important-return-value t)) (not (apply #'cl-some cl-pred cl-seq cl-rest))) ;;;###autoload (defun cl-notevery (cl-pred cl-seq &rest cl-rest) "Return true if PREDICATE is false of some element of SEQ or SEQs. \n(fn PREDICATE SEQ...)" + (declare (important-return-value t)) (not (apply #'cl-every cl-pred cl-seq cl-rest))) ;;;###autoload @@ -589,6 +597,7 @@ too large if positive or too small if negative)." ;;;###autoload (defun cl-nreconc (x y) "Equivalent to (nconc (nreverse X) Y)." + (declare (important-return-value t)) (nconc (nreverse x) y)) ;;;###autoload |