* bug#71123: [PATCH] Rename `subr-native-elisp` to `native-comp-function`
2024-05-22 17:50 bug#71123: [PATCH] Rename `subr-native-elisp` to `native-comp-function` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-05-22 18:47 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-24 7:17 ` Andrea Corallo
1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-22 18:47 UTC (permalink / raw)
To: 71123
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
And of course, I forgot to include `etc/NEWS`.
Here's an updated patch, together with the natural subsequent patch to
fix the compiler warnings due to old calls to the new obsolete function.
Stefan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Rename-subr-native-elisp-to-native-comp-function.patch --]
[-- Type: text/x-diff, Size: 5228 bytes --]
From 512c9392cac0e9682e5f3306aa4355a996541d7b Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Wed, 22 May 2024 13:45:39 -0400
Subject: [PATCH 1/2] Rename `subr-native-elisp` to `native-comp-function`
Now that this type name is displayed in *Help*, it is more
important to use a name that is less weird for the unsuspecting user.
* lisp/emacs-lisp/cl-preloaded.el (cl-functionp): Adjust to new name of
native function's type.
(subr-native-elisp-p): Redefine as an obsolete alias.
(native-comp-function): Rename from `subr-native-elisp`
* src/data.c (Fcl_type_of): Return `Qnative_comp_function` i.s.o
`Qsubr_native_elisp`.
(Fnative_comp_function_p): Rename from `Fsubr_native_elisp_p`.
(syms_of_data): Adjust accordingly.
* src/doc.c (Fsubr_documentation): Use new `Fnative_comp_function_p` name.
---
etc/NEWS | 4 ++++
lisp/emacs-lisp/cl-preloaded.el | 5 +++--
src/data.c | 12 ++++++------
src/doc.c | 2 +-
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index d72ef5b5bef..c3e2b70bbc1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1880,6 +1880,10 @@ documentation and examples.
\f
* Incompatible Lisp Changes in Emacs 30.1
+---
+** 'subr-native-elisp-p' is renamed to 'native-comp-function-p'.
+The previous name still exists but is marked as obsolete.
+
+++
** Evaluating a 'lambda' returns an object of type 'interpreted-function'.
Instead of representing interpreted functions as lists that start with
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
index fa745396b02..4b1bd2a9aff 100644
--- a/lisp/emacs-lisp/cl-preloaded.el
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -355,7 +355,7 @@ cl-functionp
This is like `functionp' except that it returns nil for all lists and symbols,
regardless if `funcall' would accept to call them."
(memq (cl-type-of object)
- '(primitive-function subr-native-elisp module-function
+ '(primitive-function native-comp-function module-function
interpreted-function byte-code-function)))
(cl--define-built-in-type t nil "Abstract supertype of everything.")
@@ -465,7 +465,8 @@ interpreted-function
"Type of functions that have not been compiled.")
(cl--define-built-in-type special-form (subr)
"Type of the core syntactic elements of the Emacs Lisp language.")
-(cl--define-built-in-type subr-native-elisp (subr compiled-function)
+(define-obsolete-function-alias 'subr-native-elisp-p #'native-comp-function-p "30.1")
+(cl--define-built-in-type native-comp-function (subr compiled-function)
"Type of functions that have been compiled by the native compiler.")
(cl--define-built-in-type primitive-function (subr compiled-function)
"Type of functions hand written in C.")
diff --git a/src/data.c b/src/data.c
index 30d8eab7359..2ff5050580d 100644
--- a/src/data.c
+++ b/src/data.c
@@ -244,7 +244,7 @@ DEFUN ("cl-type-of", Fcl_type_of, Scl_type_of, 1, 1, 0,
case PVEC_WINDOW: return Qwindow;
case PVEC_SUBR:
return XSUBR (object)->max_args == UNEVALLED ? Qspecial_form
- : SUBR_NATIVE_COMPILEDP (object) ? Qsubr_native_elisp
+ : SUBR_NATIVE_COMPILEDP (object) ? Qnative_comp_function
: Qprimitive_function;
case PVEC_CLOSURE:
return CONSP (AREF (object, CLOSURE_CODE))
@@ -1060,9 +1060,8 @@ DEFUN ("subr-name", Fsubr_name, Ssubr_name, 1, 1, 0,
return build_string (name);
}
-DEFUN ("subr-native-elisp-p", Fsubr_native_elisp_p, Ssubr_native_elisp_p, 1, 1,
- 0, doc: /* Return t if the object is native compiled lisp
-function, nil otherwise. */)
+DEFUN ("native-comp-function-p", Fnative_comp_function_p, Snative_comp_function_p, 1, 1,
+ 0, doc: /* Return t if the object is native compiled Lisp function, nil otherwise. */)
(Lisp_Object object)
{
return SUBR_NATIVE_COMPILEDP (object) ? Qt : Qnil;
@@ -4151,7 +4150,8 @@ #define PUT_ERROR(sym, tail, msg) \
DEFSYM (Qsubr, "subr");
DEFSYM (Qspecial_form, "special-form");
DEFSYM (Qprimitive_function, "primitive-function");
- DEFSYM (Qsubr_native_elisp, "subr-native-elisp");
+ DEFSYM (Qsubr_native_elisp, "subr-native-elisp"); /* Deprecated name. */
+ DEFSYM (Qnative_comp_function, "native-comp-function");
DEFSYM (Qbyte_code_function, "byte-code-function");
DEFSYM (Qinterpreted_function, "interpreted-function");
DEFSYM (Qbuffer, "buffer");
@@ -4286,7 +4286,7 @@ #define PUT_ERROR(sym, tail, msg) \
defsubr (&Sbyteorder);
defsubr (&Ssubr_arity);
defsubr (&Ssubr_name);
- defsubr (&Ssubr_native_elisp_p);
+ defsubr (&Snative_comp_function_p);
defsubr (&Ssubr_native_lambda_list);
defsubr (&Ssubr_type);
#ifdef HAVE_NATIVE_COMP
diff --git a/src/doc.c b/src/doc.c
index 36633a920c6..9cd8b60f118 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -431,7 +431,7 @@ DEFUN ("internal-subr-documentation", Fsubr_documentation, Ssubr_documentation,
(Lisp_Object function)
{
#ifdef HAVE_NATIVE_COMP
- if (!NILP (Fsubr_native_elisp_p (function)))
+ if (!NILP (Fnative_comp_function_p (function)))
return native_function_doc (function);
else
#endif
--
2.43.0
[-- Attachment #3: 0002-Redirect-calls-to-subr-native-elisp-p-to-native-comp.patch --]
[-- Type: text/x-diff, Size: 14925 bytes --]
From 2965f85459dfbafcd02c47177d6b1ee1a5aeb2d8 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Wed, 22 May 2024 14:45:35 -0400
Subject: [PATCH 2/2] Redirect calls to `subr-native-elisp-p` to
`native-comp-function-p`
* test/src/comp-tests.el (comp-tests-bootstrap, lambda-return)
(lambda-return2, free-fun, free-fun2, free-fun-silly-name, speed--1)
(compile-forms, comp-test-defsubst, primitive-redefine-compile-44221)
(48029-1, 61917-1, tco, fw-prop-1, pure):
* test/lisp/help-fns-tests.el (help-fns-test-lisp-defun):
* lisp/subr.el (subr-primitive-p, primitive-function-p, symbol-file):
* lisp/help-fns.el (find-lisp-object-file-name):
* lisp/emacs-lisp/disass.el (disassemble-internal):
* lisp/emacs-lisp/comp.el (comp--call-optim-form-call):
* lisp/emacs-lisp/comp-run.el (comp-warn-primitives):
* lisp/emacs-lisp/comp-common.el (comp-function-type-spec):
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns):
* lisp/emacs-lisp/bytecomp.el (<trailer>): Rename `subr-native-elisp-p`
to `native-comp-function-p`.
---
lisp/emacs-lisp/byte-opt.el | 5 +++--
lisp/emacs-lisp/bytecomp.el | 2 +-
lisp/emacs-lisp/comp-common.el | 2 +-
lisp/emacs-lisp/comp-run.el | 2 +-
lisp/emacs-lisp/comp.el | 2 +-
lisp/emacs-lisp/disass.el | 4 ++--
lisp/help-fns.el | 2 +-
lisp/subr.el | 8 +++----
test/lisp/help-fns-tests.el | 2 +-
test/src/comp-tests.el | 40 +++++++++++++++++-----------------
10 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 4095726d276..c060c8d676b 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1876,9 +1876,10 @@ byte-optimize-set
byteorder car-safe cdr-safe char-or-string-p char-table-p
condition-variable-p consp eq floatp indirect-function
integer-or-marker-p integerp keywordp listp markerp
- module-function-p multibyte-string-p mutexp natnump nlistp null
+ module-function-p multibyte-string-p mutexp native-comp-function-p
+ natnump nlistp null
number-or-marker-p numberp recordp remove-pos-from-symbol
- sequencep stringp subr-native-elisp-p subrp symbol-with-pos-p symbolp
+ sequencep stringp subrp symbol-with-pos-p symbolp
threadp type-of user-ptrp vector-or-char-table-p vectorp wholenump
;; editfns.c
bobp bolp buffer-size buffer-string current-message emacs-pid
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 12b45f9f5b8..03cfbe6f4c9 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -6028,7 +6028,7 @@ byte-compile-report-ops
(let ((byte-optimize nil) ; do it fast
(byte-compile-warnings nil))
(mapc (lambda (x)
- (unless (subr-native-elisp-p x)
+ (unless (native-comp-function-p x)
(or noninteractive (message "compiling %s..." x))
(byte-compile x)
(or noninteractive (message "compiling %s...done" x))))
diff --git a/lisp/emacs-lisp/comp-common.el b/lisp/emacs-lisp/comp-common.el
index 355988838c7..ce6296953bf 100644
--- a/lisp/emacs-lisp/comp-common.el
+++ b/lisp/emacs-lisp/comp-common.el
@@ -518,7 +518,7 @@ comp-function-type-spec
(if-let ((delc-type (function-get function 'function-type)))
;; Declared Lisp function
(setf type-spec delc-type)
- (when (subr-native-elisp-p f)
+ (when (native-comp-function-p f)
;; Native compiled inferred
(setf kind 'inferred
type-spec (subr-type f))))))
diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el
index 5cc61579030..f159c5b1911 100644
--- a/lisp/emacs-lisp/comp-run.el
+++ b/lisp/emacs-lisp/comp-run.el
@@ -341,7 +341,7 @@ comp-run-async-workers
(clrhash comp-deferred-pending-h)))
(defconst comp-warn-primitives
- '(null memq gethash and subrp not subr-native-elisp-p
+ '(null memq gethash and subrp not native-comp-function-p
comp--install-trampoline concat if symbolp symbol-name make-string
length aset aref length> mapcar expand-file-name
file-name-as-directory file-exists-p native-elisp-load)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 4c76f95a0e9..32d4442ca1b 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2847,7 +2847,7 @@ comp--call-optim-form-call
(subrp (subrp f))
(comp-func-callee (comp--func-in-unit callee)))
(cond
- ((and subrp (not (subr-native-elisp-p f)))
+ ((and subrp (not (native-comp-function-p f)))
;; Trampoline removal.
(let* ((callee (intern (subr-name f))) ; Fix aliased names.
(maxarg (cdr (subr-arity f)))
diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
index 91427166137..07072f2a2be 100644
--- a/lisp/emacs-lisp/disass.el
+++ b/lisp/emacs-lisp/disass.el
@@ -91,8 +91,8 @@ disassemble-internal
args)
(setq obj (autoload-do-load obj name))
(if (subrp obj)
- (if (and (fboundp 'subr-native-elisp-p)
- (subr-native-elisp-p obj))
+ (if (and (fboundp 'native-comp-function-p)
+ (native-comp-function-p obj))
(progn
(require 'comp)
(let ((eln (native-comp-unit-file (subr-native-comp-unit obj))))
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 182b22549b5..af27d101ac8 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -475,7 +475,7 @@ find-lisp-object-file-name
(cond
((and (not file-name)
(subrp type)
- (not (subr-native-elisp-p type)))
+ (not (native-comp-function-p type)))
;; A built-in function. The form is from `describe-function-1'.
(if (or (get-buffer " *DOC*")
(and also-c-source
diff --git a/lisp/subr.el b/lisp/subr.el
index d6481fdf73e..d171ac7adac 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -316,14 +316,14 @@ subr-primitive-p
Such objects can be functions or special forms."
(declare (side-effect-free error-free))
(and (subrp object)
- (not (subr-native-elisp-p object))))
+ (not (native-comp-function-p object))))
(defsubst primitive-function-p (object)
"Return t if OBJECT is a built-in primitive function.
This excludes special forms, since they are not functions."
(declare (side-effect-free error-free))
(and (subrp object)
- (not (or (subr-native-elisp-p object)
+ (not (or (native-comp-function-p object)
(eq (cdr (subr-arity object)) 'unevalled)))))
(defsubst xor (cond1 cond2)
@@ -3022,7 +3022,7 @@ define-symbol-prop
(defvar comp-native-version-dir)
(defvar native-comp-eln-load-path)
-(declare-function subr-native-elisp-p "data.c")
+(declare-function native-comp-function-p "data.c")
(declare-function native-comp-unit-file "data.c")
(declare-function subr-native-comp-unit "data.c")
(declare-function comp-el-to-eln-rel-filename "comp.c")
@@ -3071,7 +3071,7 @@ symbol-file
(symbolp symbol)
(native-comp-available-p)
;; If it's a defun, we have a shortcut.
- (subr-native-elisp-p (symbol-function symbol)))
+ (native-comp-function-p (symbol-function symbol)))
;; native-comp-unit-file returns unnormalized file names.
(expand-file-name (native-comp-unit-file (subr-native-comp-unit
(symbol-function symbol))))
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index 82350a4bc71..7393a2624fe 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -67,7 +67,7 @@ help-fns-test-lisp-defun
(result (help-fns-tests--describe-function 'last)))
(should (string-match regexp result))
(should (member (match-string 1 result)
- '("subr-native-elisp" "byte-code-function")))))
+ '("native-comp-function" "byte-code-function")))))
(ert-deftest help-fns-test-lisp-defsubst ()
(let ((regexp "a byte-code-function in .+subr\\.el")
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index 5deff03fd84..dffb7097a3e 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -85,13 +85,13 @@ comp-tests-bootstrap
(copy-file comp-src comp2-src t)
(let ((load-no-native t))
(load (concat comp-src "c") nil nil t t))
- (should-not (subr-native-elisp-p (symbol-function 'native-compile)))
+ (should-not (native-comp-function-p (symbol-function 'native-compile)))
(message "Compiling stage1...")
(let* ((t0 (current-time))
(comp1-eln (native-compile comp1-src)))
(message "Done in %d secs" (float-time (time-since t0)))
(load comp1-eln nil nil t t)
- (should (subr-native-elisp-p (symbol-function 'native-compile)))
+ (should (native-comp-function-p (symbol-function 'native-compile)))
(message "Compiling stage2...")
(let ((t0 (current-time))
(comp2-eln (native-compile comp2-src)))
@@ -325,15 +325,15 @@ buffer
(comp-deftest lambda-return ()
(let ((f (comp-tests-lambda-return-f)))
- (should (subr-native-elisp-p f))
+ (should (native-comp-function-p f))
(should (= (funcall f 3) 4))))
(comp-deftest lambda-return2 ()
"Check a nested lambda function gets native compiled."
(let ((f (comp-tests-lambda-return-f2)))
- (should (subr-native-elisp-p f))
+ (should (native-comp-function-p f))
(let ((f2 (funcall f)))
- (should (subr-native-elisp-p f2))
+ (should (native-comp-function-p f2))
(should (= (funcall f2 3) 4)))))
(comp-deftest recursive ()
@@ -391,7 +391,7 @@ free-fun
t)
(native-compile #'comp-tests-free-fun-f)
- (should (subr-native-elisp-p (symbol-function 'comp-tests-free-fun-f)))
+ (should (native-comp-function-p (symbol-function 'comp-tests-free-fun-f)))
(should (= (comp-tests-free-fun-f) 3))
(should (string= (documentation #'comp-tests-free-fun-f)
"Some doc."))
@@ -412,8 +412,8 @@ free-fun2
(let* ((f (symbol-function 'comp-tests-free-fun-f2))
(f2 (funcall f)))
- (should (subr-native-elisp-p f))
- (should (subr-native-elisp-p f2))
+ (should (native-comp-function-p f))
+ (should (native-comp-function-p f2))
(should (string= (documentation f2) "Some doc."))
(should (commandp f2))
(should (equal (interactive-form f2) '(interactive nil)))
@@ -425,7 +425,7 @@ free-fun-silly-name
"Check we are able to compile a single function."
(eval '(defun comp-tests/free\fun-f ()) t)
(native-compile #'comp-tests/free\fun-f)
- (should (subr-native-elisp-p (symbol-function 'comp-tests/free\fun-f))))
+ (should (native-comp-function-p (symbol-function 'comp-tests/free\fun-f))))
(comp-deftest bug-40187 ()
"Check function name shadowing.
@@ -436,7 +436,7 @@ bug-40187
(comp-deftest speed--1 ()
"Check that at speed -1 we do not native compile."
(should (= (comp-test-speed--1-f) 3))
- (should-not (subr-native-elisp-p (symbol-function 'comp-test-speed--1-f))))
+ (should-not (native-comp-function-p (symbol-function 'comp-test-speed--1-f))))
(comp-deftest bug-42360 ()
"<https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-07/msg00418.html>."
@@ -497,22 +497,22 @@ compile-forms
(should-error (native-compile '(+ 1 foo)))
(let ((lexical-binding t)
(f (native-compile '(lambda (x) (1+ x)))))
- (should (subr-native-elisp-p f))
+ (should (native-comp-function-p f))
(should (= (funcall f 2) 3)))
(let* ((lexical-binding nil)
(f (native-compile '(lambda (x) (1+ x)))))
- (should (subr-native-elisp-p f))
+ (should (native-comp-function-p f))
(should (= (funcall f 2) 3))))
(comp-deftest comp-test-defsubst ()
;; Bug#42664, Bug#43280, Bug#44209.
- (should-not (subr-native-elisp-p (symbol-function 'comp-test-defsubst-f))))
+ (should-not (native-comp-function-p (symbol-function 'comp-test-defsubst-f))))
(comp-deftest primitive-redefine-compile-44221 ()
"Test the compiler still works while primitives are redefined (bug#44221)."
(cl-letf (((symbol-function 'delete-region)
(lambda (_ _))))
- (should (subr-native-elisp-p
+ (should (native-comp-function-p
(native-compile
'(lambda ()
(delete-region (point-min) (point-max))))))))
@@ -564,7 +564,7 @@ comp-test-47868-1
(comp-deftest 48029-1 ()
"<https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-07/msg00666.html>"
- (should (subr-native-elisp-p
+ (should (native-comp-function-p
(symbol-function 'comp-test-48029-nonascii-žžž-f))))
(comp-deftest 61917-1 ()
@@ -578,7 +578,7 @@ 61917-1
(setf x (native-compile
'(lambda ()
(delete-region 1 2))))
- (should (subr-native-elisp-p x))
+ (should (native-comp-function-p x))
(funcall x)
(advice-remove #'delete-region f)
(should (equal comp-test-primitive-redefine-args '(1 2))))))
@@ -874,7 +874,7 @@ tco
(comp-tests-tco-f (+ a b) a (- count 1))))
t)
(native-compile #'comp-tests-tco-f)
- (should (subr-native-elisp-p (symbol-function 'comp-tests-tco-f)))
+ (should (native-comp-function-p (symbol-function 'comp-tests-tco-f)))
(should (= (comp-tests-tco-f 1 0 10) 55))))
(defun comp-tests-fw-prop-checker-1 (_)
@@ -901,7 +901,7 @@ fw-prop-1
(length c))) ; <= has to optimize
t)
(native-compile #'comp-tests-fw-prop-1-f)
- (should (subr-native-elisp-p (symbol-function 'comp-tests-fw-prop-1-f)))
+ (should (native-comp-function-p (symbol-function 'comp-tests-fw-prop-1-f)))
(should (= (comp-tests-fw-prop-1-f) 6))))
(defun comp-tests--type-lists-equal (l1 l2)
@@ -1556,10 +1556,10 @@ pure
(declare-function comp-tests-pure-caller-f nil)
(declare-function comp-tests-pure-fibn-entry-f nil)
- (should (subr-native-elisp-p (symbol-function 'comp-tests-pure-caller-f)))
+ (should (native-comp-function-p (symbol-function 'comp-tests-pure-caller-f)))
(should (= (comp-tests-pure-caller-f) 4))
- (should (subr-native-elisp-p (symbol-function 'comp-tests-pure-fibn-entry-f)))
+ (should (native-comp-function-p (symbol-function 'comp-tests-pure-fibn-entry-f)))
(should (= (comp-tests-pure-fibn-entry-f) 6765))))
(defvar comp-tests-cond-rw-checked-function nil
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread