1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Declare caar, cadr, etc. as side-effect-free

* lisp/subr.el (caar, cadr, cdar, cddr, caaar, caadr, cadar, caddr)
(cdaar, cdadr, cddar, cdddr, caaaar, caaadr, caadar, caaddr, cadaar)
(cadadr, caddar, cadddr, cdaaar, cdaadr, cdadar, cdaddr, cddaar)
(cddadr, cdddar, cddddr): Declare side-effect-free.
* lisp/emacs-lisp/cl-macs.el: Remove redundant declarations of
compatibility aliases for the above functions as side-effect-free.
This commit is contained in:
Stefan Kangas 2025-02-12 18:05:11 +01:00
parent 31381f982d
commit f478d2d1b9
2 changed files with 57 additions and 37 deletions

View file

@ -3731,15 +3731,7 @@ macro that returns its `&whole' argument."
(dolist (y '(cl-first cl-second cl-third cl-fourth (dolist (y '(cl-first cl-second cl-third cl-fourth
cl-fifth cl-sixth cl-seventh cl-fifth cl-sixth cl-seventh
cl-eighth cl-ninth cl-tenth cl-eighth cl-ninth cl-tenth
cl-rest cl-endp cl-plusp cl-minusp cl-rest cl-endp cl-plusp cl-minusp))
cl-caaar cl-caadr cl-cadar
cl-caddr cl-cdaar cl-cdadr
cl-cddar cl-cdddr cl-caaaar
cl-caaadr cl-caadar cl-caaddr
cl-cadaar cl-cadadr cl-caddar
cl-cadddr cl-cdaaar cl-cdaadr
cl-cdadar cl-cdaddr cl-cddaar
cl-cddadr cl-cdddar cl-cddddr))
(put y 'side-effect-free t)) (put y 'side-effect-free t))
;;; Things that are inline. ;;; Things that are inline.

View file

@ -609,142 +609,170 @@ treatment of negative COUNT provided by this function."
(defun caar (x) (defun caar (x)
"Return the car of the car of X." "Return the car of the car of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car x))) (car (car x)))
(defun cadr (x) (defun cadr (x)
"Return the car of the cdr of X." "Return the car of the cdr of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr x))) (car (cdr x)))
(defun cdar (x) (defun cdar (x)
"Return the cdr of the car of X." "Return the cdr of the car of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car x))) (cdr (car x)))
(defun cddr (x) (defun cddr (x)
"Return the cdr of the cdr of X." "Return the cdr of the cdr of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr x))) (cdr (cdr x)))
(defun caaar (x) (defun caaar (x)
"Return the `car' of the `car' of the `car' of X." "Return the `car' of the `car' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car (car x)))) (car (car (car x))))
(defun caadr (x) (defun caadr (x)
"Return the `car' of the `car' of the `cdr' of X." "Return the `car' of the `car' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car (cdr x)))) (car (car (cdr x))))
(defun cadar (x) (defun cadar (x)
"Return the `car' of the `cdr' of the `car' of X." "Return the `car' of the `cdr' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr (car x)))) (car (cdr (car x))))
(defun caddr (x) (defun caddr (x)
"Return the `car' of the `cdr' of the `cdr' of X." "Return the `car' of the `cdr' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr (cdr x)))) (car (cdr (cdr x))))
(defun cdaar (x) (defun cdaar (x)
"Return the `cdr' of the `car' of the `car' of X." "Return the `cdr' of the `car' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car (car x)))) (cdr (car (car x))))
(defun cdadr (x) (defun cdadr (x)
"Return the `cdr' of the `car' of the `cdr' of X." "Return the `cdr' of the `car' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car (cdr x)))) (cdr (car (cdr x))))
(defun cddar (x) (defun cddar (x)
"Return the `cdr' of the `cdr' of the `car' of X." "Return the `cdr' of the `cdr' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr (car x)))) (cdr (cdr (car x))))
(defun cdddr (x) (defun cdddr (x)
"Return the `cdr' of the `cdr' of the `cdr' of X." "Return the `cdr' of the `cdr' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr (cdr x)))) (cdr (cdr (cdr x))))
(defun caaaar (x) (defun caaaar (x)
"Return the `car' of the `car' of the `car' of the `car' of X." "Return the `car' of the `car' of the `car' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car (car (car x))))) (car (car (car (car x)))))
(defun caaadr (x) (defun caaadr (x)
"Return the `car' of the `car' of the `car' of the `cdr' of X." "Return the `car' of the `car' of the `car' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car (car (cdr x))))) (car (car (car (cdr x)))))
(defun caadar (x) (defun caadar (x)
"Return the `car' of the `car' of the `cdr' of the `car' of X." "Return the `car' of the `car' of the `cdr' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car (cdr (car x))))) (car (car (cdr (car x)))))
(defun caaddr (x) (defun caaddr (x)
"Return the `car' of the `car' of the `cdr' of the `cdr' of X." "Return the `car' of the `car' of the `cdr' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (car (cdr (cdr x))))) (car (car (cdr (cdr x)))))
(defun cadaar (x) (defun cadaar (x)
"Return the `car' of the `cdr' of the `car' of the `car' of X." "Return the `car' of the `cdr' of the `car' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr (car (car x))))) (car (cdr (car (car x)))))
(defun cadadr (x) (defun cadadr (x)
"Return the `car' of the `cdr' of the `car' of the `cdr' of X." "Return the `car' of the `cdr' of the `car' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr (car (cdr x))))) (car (cdr (car (cdr x)))))
(defun caddar (x) (defun caddar (x)
"Return the `car' of the `cdr' of the `cdr' of the `car' of X." "Return the `car' of the `cdr' of the `cdr' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr (cdr (car x))))) (car (cdr (cdr (car x)))))
(defun cadddr (x) (defun cadddr (x)
"Return the `car' of the `cdr' of the `cdr' of the `cdr' of X." "Return the `car' of the `cdr' of the `cdr' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(car (cdr (cdr (cdr x))))) (car (cdr (cdr (cdr x)))))
(defun cdaaar (x) (defun cdaaar (x)
"Return the `cdr' of the `car' of the `car' of the `car' of X." "Return the `cdr' of the `car' of the `car' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car (car (car x))))) (cdr (car (car (car x)))))
(defun cdaadr (x) (defun cdaadr (x)
"Return the `cdr' of the `car' of the `car' of the `cdr' of X." "Return the `cdr' of the `car' of the `car' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car (car (cdr x))))) (cdr (car (car (cdr x)))))
(defun cdadar (x) (defun cdadar (x)
"Return the `cdr' of the `car' of the `cdr' of the `car' of X." "Return the `cdr' of the `car' of the `cdr' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car (cdr (car x))))) (cdr (car (cdr (car x)))))
(defun cdaddr (x) (defun cdaddr (x)
"Return the `cdr' of the `car' of the `cdr' of the `cdr' of X." "Return the `cdr' of the `car' of the `cdr' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (car (cdr (cdr x))))) (cdr (car (cdr (cdr x)))))
(defun cddaar (x) (defun cddaar (x)
"Return the `cdr' of the `cdr' of the `car' of the `car' of X." "Return the `cdr' of the `cdr' of the `car' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr (car (car x))))) (cdr (cdr (car (car x)))))
(defun cddadr (x) (defun cddadr (x)
"Return the `cdr' of the `cdr' of the `car' of the `cdr' of X." "Return the `cdr' of the `cdr' of the `car' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr (car (cdr x))))) (cdr (cdr (car (cdr x)))))
(defun cdddar (x) (defun cdddar (x)
"Return the `cdr' of the `cdr' of the `cdr' of the `car' of X." "Return the `cdr' of the `cdr' of the `cdr' of the `car' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr (cdr (car x))))) (cdr (cdr (cdr (car x)))))
(defun cddddr (x) (defun cddddr (x)
"Return the `cdr' of the `cdr' of the `cdr' of the `cdr' of X." "Return the `cdr' of the `cdr' of the `cdr' of the `cdr' of X."
(declare (compiler-macro internal--compiler-macro-cXXr)) (declare (side-effect-free t)
(compiler-macro internal--compiler-macro-cXXr))
(cdr (cdr (cdr (cdr x))))) (cdr (cdr (cdr (cdr x)))))
(defun last (list &optional n) (defun last (list &optional n)