emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/func-type-decls 45e94db72df 2/6: Move remaning declared types ou


From: Andrea Corallo
Subject: scratch/func-type-decls 45e94db72df 2/6: Move remaning declared types out of comp-known-type-specifiers
Date: Fri, 23 Feb 2024 10:12:12 -0500 (EST)

branch: scratch/func-type-decls
commit 45e94db72df51b26b7d2c41cd64237b9a2d3f0c4
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    Move remaning declared types out of comp-known-type-specifiers
---
 lisp/custom.el                 |  3 ++-
 lisp/emacs-lisp/comp-common.el | 45 +++++++-----------------------------------
 lisp/emacs-lisp/comp.el        |  6 ++++--
 lisp/emacs-lisp/lisp.el        |  3 ++-
 lisp/emacs-lisp/regexp-opt.el  |  3 ++-
 lisp/env.el                    |  3 ++-
 lisp/simple.el                 |  9 ++++++---
 lisp/subr.el                   | 36 ++++++++++++++++++++++-----------
 lisp/window.el                 |  9 ++++++---
 9 files changed, 55 insertions(+), 62 deletions(-)

diff --git a/lisp/custom.el b/lisp/custom.el
index a19b14aaf8a..f82cb26d929 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -667,7 +667,8 @@ If NOSET is non-nil, don't bother autoloading LOAD when 
setting the variable."
 A customizable variable is either (i) a variable whose property
 list contains a non-nil `standard-value' or `custom-autoload'
 property, or (ii) an alias for another customizable variable."
-  (declare (side-effect-free t))
+  (declare (function (symbol) t)
+           (side-effect-free t))
   (when (symbolp variable)
     (setq variable (indirect-variable variable))
     (or (get variable 'standard-value)
diff --git a/lisp/emacs-lisp/comp-common.el b/lisp/emacs-lisp/comp-common.el
index fe9c6f87565..f2806c16aca 100644
--- a/lisp/emacs-lisp/comp-common.el
+++ b/lisp/emacs-lisp/comp-common.el
@@ -73,44 +73,13 @@ Used to modify the compiler environment."
   ;; to expose the same type.  The vast majority of these are
   ;; either pure or primitive; the original list is the union of
   ;; pure + side-effect-free-fns + side-effect-and-error-free-fns:
-  `((bignump (function (t) boolean))
-    (buffer-end (function ((or number marker)) integer))
-    (count-lines
-     (function ((or integer marker) (or integer marker) &optional t) integer))
-    (custom-variable-p (function (symbol) t))
-    (degrees-to-radians (function (number) float))
-    (eventp (function (t) boolean))
-    (fixnump (function (t) boolean))
-    (get-largest-window (function (&optional t t t) (or window null)))
-    (get-lru-window (function (&optional t t t) (or window null)))
-    (getenv (function (string &optional frame) (or null string)))
-    (ignore (function (&rest t) null))
-    (interactive-p (function () boolean))
-    (last (function (list &optional integer) list))
-    (lax-plist-get (function (list t) t))
-    (log10 (function (number) float))
-    ;; (lsh (function ((integer ,most-negative-fixnum *) integer) integer)) ?
-    (lsh (function (integer integer) integer))
-    (mark (function (&optional t) (or integer null)))
-    (memory-limit (function () integer))
-    (mouse-movement-p (function (t) boolean))
-    (one-window-p (function (&optional t t) boolean))
-    (radians-to-degrees (function (number) float))
-    (regexp-opt (function (list) string))
-    (zerop (function (number) boolean))
-    ;; Type hints
-    (comp-hint-fixnum (function (t) fixnum))
-    (comp-hint-cons (function (t) cons))
-    ;; Non returning functions
-    (error (function (string &rest t) nil))
-    ;; Primitives
-    ,@(let (res)
-        (mapatoms (lambda (atom)
-                    (when-let ((f (symbol-function atom))
-                               (primitive (subr-primitive-p f))
-                               (type (subr-type f)))
-                      (push `(,atom ,type) res))))
-        res))
+  (let (res)
+    (mapatoms (lambda (atom)
+                (when-let ((f (symbol-function atom))
+                           (primitive (subr-primitive-p f))
+                           (type (subr-type f)))
+                  (push `(,atom ,type) res))))
+    res)
   "Alist used for type propagation.")
 
 
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index e0da01bcc5d..12462abea91 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -3229,11 +3229,13 @@ Prepare every function for final compilation and drive 
the C back-end."
 ;; are assumed just to be true. Use with extreme caution...
 
 (defun comp-hint-fixnum (x)
-  (declare (gv-setter (lambda (val) `(setf ,x ,val))))
+  (declare (function (t) fixnum)
+           (gv-setter (lambda (val) `(setf ,x ,val))))
   x)
 
 (defun comp-hint-cons (x)
-  (declare (gv-setter (lambda (val) `(setf ,x ,val))))
+  (declare (function (t) cons)
+           (gv-setter (lambda (val) `(setf ,x ,val))))
   x)
 
 
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index c57b1357f63..cbd016e6e2d 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -530,7 +530,8 @@ major mode's decisions about context.")
   "Return the \"far end\" position of the buffer, in direction ARG.
 If ARG is positive, that's the end of the buffer.
 Otherwise, that's the beginning of the buffer."
-  (declare (side-effect-free error-free))
+  (declare (function ((or number marker)) integer)
+           (side-effect-free error-free))
   (if (> arg 0) (point-max) (point-min)))
 
 (defun end-of-defun (&optional arg interactive)
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index 59c1b7d8e10..10a98f44ef4 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -130,7 +130,8 @@ usually more efficient than that of a simplified version:
      (concat (car parens)
              (mapconcat \\='regexp-quote strings \"\\\\|\")
              (cdr parens))))"
-  (declare (pure t) (side-effect-free t))
+  (declare (function (list) string)
+           (pure t) (side-effect-free t))
   (save-match-data
     ;; Recurse on the sorted list.
     (let* ((max-lisp-eval-depth 10000)
diff --git a/lisp/env.el b/lisp/env.el
index e0a8df8476c..9487e1df964 100644
--- a/lisp/env.el
+++ b/lisp/env.el
@@ -207,7 +207,8 @@ parameter.
 Otherwise, this function searches `process-environment' for
 VARIABLE.  If it is not found there, then it continues the search
 in the environment list of the selected frame."
-  (declare (side-effect-free t))
+  (declare (function (string &optional frame) (or null string))
+           (side-effect-free t))
   (interactive (list (read-envvar-name "Get environment variable: " t)))
   (let ((value (getenv-internal (if (multibyte-string-p variable)
                                    (encode-coding-string
diff --git a/lisp/simple.el b/lisp/simple.el
index 9a33049f4ca..aba4181ef3c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1762,7 +1762,8 @@ not at the start of a line.
 
 When IGNORE-INVISIBLE-LINES is non-nil, invisible lines are not
 included in the count."
-  (declare (side-effect-free t))
+  (declare (function ((or integer marker) (or integer marker) &optional t) 
integer)
+           (side-effect-free t))
   (save-excursion
     (save-restriction
       (narrow-to-region start end)
@@ -6883,7 +6884,8 @@ is active, and returns an integer or nil in the usual way.
 
 If you are using this in an editing command, you are most likely making
 a mistake; see the documentation of `set-mark'."
-  (declare (side-effect-free t))
+  (declare (function (&optional t) (or integer null))
+           (side-effect-free t))
   (if (or force (not transient-mark-mode) mark-active mark-even-if-inactive)
       (marker-position (mark-marker))
     (signal 'mark-inactive nil)))
@@ -11160,7 +11162,8 @@ killed."
 
 (defun lax-plist-get (plist prop)
   "Extract a value from a property list, comparing with `equal'."
-  (declare (pure t) (side-effect-free t) (obsolete plist-get "29.1"))
+  (declare (function (list t) t)
+           (pure t) (side-effect-free t) (obsolete plist-get "29.1"))
   (plist-get plist prop #'equal))
 
 (defun lax-plist-put (plist prop val)
diff --git a/lisp/subr.el b/lisp/subr.el
index c317d558e24..c0face32883 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -442,7 +442,8 @@ This function accepts any number of arguments in ARGUMENTS.
 Also see `always'."
   ;; Not declared `side-effect-free' because we don't want calls to it
   ;; elided; see `byte-compile-ignore'.
-  (declare (pure t) (completion ignore))
+  (declare (function (&rest t) null)
+           (pure t) (completion ignore))
   (interactive)
   nil)
 
@@ -471,7 +472,8 @@ for the sake of consistency.
 
 To alter the look of the displayed error messages, you can use
 the `command-error-function' variable."
-  (declare (advertised-calling-convention (string &rest args) "23.1"))
+  (declare (function (string &rest t) nil)
+           (advertised-calling-convention (string &rest args) "23.1"))
   (signal 'error (list (apply #'format-message args))))
 
 (defun user-error (format &rest args)
@@ -536,19 +538,22 @@ was called."
   "Return t if NUMBER is zero."
   ;; Used to be in C, but it's pointless since (= 0 n) is faster anyway because
   ;; = has a byte-code.
-  (declare (pure t) (side-effect-free t)
+  (declare (function (number) boolean)
+           (pure t) (side-effect-free t)
            (compiler-macro (lambda (_) `(= 0 ,number))))
   (= 0 number))
 
 (defun fixnump (object)
   "Return t if OBJECT is a fixnum."
-  (declare (side-effect-free error-free))
+  (declare (function (t) boolean)
+           (side-effect-free error-free))
   (and (integerp object)
        (<= most-negative-fixnum object most-positive-fixnum)))
 
 (defun bignump (object)
   "Return t if OBJECT is a bignum."
-  (declare (side-effect-free error-free))
+  (declare (function (t) boolean)
+           (side-effect-free error-free))
   (and (integerp object) (not (fixnump object))))
 
 (defun lsh (value count)
@@ -561,7 +566,8 @@ Most uses of this function turn out to be mistakes.  We 
recommend
 to use `ash' instead, unless COUNT could ever be negative, and
 if, when COUNT is negative, your program really needs the special
 treatment of negative COUNT provided by this function."
-  (declare (compiler-macro
+  (declare (function (integer integer) integer)
+           (compiler-macro
             (lambda (form)
               (macroexp-warn-and-return
                (format-message "avoid `lsh'; use `ash' instead")
@@ -739,7 +745,8 @@ treatment of negative COUNT provided by this function."
 If LIST is nil, return nil.
 If N is non-nil, return the Nth-to-last link of LIST.
 If N is bigger than the length of LIST, return LIST."
-  (declare (pure t) (side-effect-free t))    ; pure up to mutation
+  (declare (function (list &optional integer) list)
+           (pure t) (side-effect-free t))    ; pure up to mutation
   (if n
       (and (>= n 0)
            (let ((m (safe-length list)))
@@ -1576,7 +1583,8 @@ See also `current-global-map'.")
 
 (defun eventp (object)
   "Return non-nil if OBJECT is an input event or event object."
-  (declare (pure t) (side-effect-free error-free))
+  (declare (function (t) boolean)
+           (pure t) (side-effect-free error-free))
   (or (integerp object)
       (and (if (consp object)
                (setq object (car object))
@@ -1643,7 +1651,8 @@ in the current Emacs session, then this function may 
return nil."
 
 (defsubst mouse-movement-p (object)
   "Return non-nil if OBJECT is a mouse movement event."
-  (declare (side-effect-free error-free))
+  (declare (function (t) boolean)
+           (side-effect-free error-free))
   (eq (car-safe object) 'mouse-movement))
 
 (defun mouse-event-p (object)
@@ -1952,7 +1961,8 @@ be a list of the form returned by `event-start' and 
`event-end'."
 
 (defun log10 (x)
   "Return (log X 10), the log base 10 of X."
-  (declare (side-effect-free t) (obsolete log "24.4"))
+  (declare (function (number) float)
+           (side-effect-free t) (obsolete log "24.4"))
   (log x 10))
 
 (set-advertised-calling-convention
@@ -3232,7 +3242,8 @@ It can be retrieved with `(process-get PROCESS 
PROPNAME)'."
 
 (defun memory-limit ()
   "Return an estimate of Emacs virtual memory usage, divided by 1024."
-  (declare (side-effect-free error-free))
+  (declare (function () integer)
+           (side-effect-free error-free))
   (let ((default-directory temporary-file-directory))
     (or (cdr (assq 'vsize (process-attributes (emacs-pid)))) 0)))
 
@@ -6524,7 +6535,8 @@ To test whether a function can be called interactively, 
use
 `commandp'."
   ;; Kept around for now.  See discussion at:
   ;; https://lists.gnu.org/r/emacs-devel/2020-08/msg00564.html
-  (declare (obsolete called-interactively-p "23.2")
+  (declare (function () boolean)
+           (obsolete called-interactively-p "23.2")
            (side-effect-free error-free))
   (called-interactively-p 'interactive))
 
diff --git a/lisp/window.el b/lisp/window.el
index 6df20353b5e..9b90d36ce4a 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2515,7 +2515,8 @@ have special meanings:
 
 Any other value of ALL-FRAMES means consider all windows on the
 selected frame and no others."
-  (declare (side-effect-free error-free))
+  (declare (function (&optional t t t) (or window null))
+           (side-effect-free error-free))
   (let ((windows (window-list-1 nil 'nomini all-frames))
         best-window best-time second-best-window second-best-time time)
     (dolist (window windows)
@@ -2594,7 +2595,8 @@ have special meanings:
 
 Any other value of ALL-FRAMES means consider all windows on the
 selected frame and no others."
-  (declare (side-effect-free error-free))
+  (declare (function (&optional t t t) (or window null))
+           (side-effect-free error-free))
   (let ((best-size 0)
        best-window size)
     (dolist (window (window-list-1 nil 'nomini all-frames))
@@ -4089,7 +4091,8 @@ with a special meaning are:
 
 Anything else means consider all windows on the selected frame
 and no others."
-  (declare (side-effect-free error-free))
+  (declare (function (&optional t t) boolean)
+           (side-effect-free error-free))
   (let ((base-window (selected-window)))
     (if (and nomini (eq base-window (minibuffer-window)))
        (setq base-window (next-window base-window)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]