emacs/test/lisp/emacs-lisp
Stefan Monnier f2bccae22b Use a dedicated type to represent interpreted-function values
Change `function` so that when evaluating #'(lambda ...)
we return an object of type `interpreted-function` rather than
a list starting with one of `lambda` or `closure`.
The new type reuses the existing PVEC_CLOSURE (nee PVEC_COMPILED)
tag and tries to align the corresponding elements:

- the arglist, the docstring, and the interactive-form go in the
  same slots as for byte-code functions.
- the body of the function goes in the slot used for the bytecode string.
- the lexical context goes in the slot used for the constants of
  bytecoded functions.

The first point above means that `help-function-arglist`,
`documentation`, and `interactive-form`s don't need to
distinguish interpreted and bytecode functions any more.

Main benefits of the change:

- We can now reliably distinguish a list from a function value.
- `cl-defmethod` can dispatch on `interactive-function` and `closure`.
  Dispatch on `function` also works now for interpreted functions but still
  won't work for functions represented as lists or as symbols, of course.
- Function values are now self-evaluating.  That was alrready the case
  when byte-compiled, but not when interpreted since
  (eval '(closure ...)) signals a void-function error.
  That also avoids false-positive warnings about "don't quote your lambdas"
  when doing things like `(mapcar ',func ...)`.

* src/eval.c (Fmake_interpreted_closure): New function.
(Ffunction): Use it and change calling convention of
`Vinternal_make_interpreted_closure_function`.
(FUNCTIONP, Fcommandp, eval_sub, funcall_general, funcall_lambda)
(Ffunc_arity, lambda_arity): Simplify.
(funcall_lambda): Adjust to new representation.
(syms_of_eval): `defsubr` the new function.  Remove definition of `Qclosure`.

* lisp/emacs-lisp/cconv.el (cconv-make-interpreted-closure):
Change calling convention and use `make-interpreted-closure`.

* src/data.c (Fcl_type_of): Distinguish `byte-code-function`s from
`interpreted-function`s.
(Fclosurep, finterpreted_function_p): New functions.
(Fbyte_code_function_p): Don't be confused by `interpreted-function`s.
(Finteractive_form, Fcommand_modes): Simplify.
(syms_of_data): Define new type symbols and `defsubr` the two
new functions.

* lisp/emacs-lisp/cl-print.el (cl-print-object) <interpreted-function>:
New method.

* lisp/emacs-lisp/oclosure.el (oclosure): Refine the parent
to be `closure`.
(oclosure--fix-type, oclosure-type): Simplify.
(oclosure--copy, oclosure--get, oclosure--set): Adjust to
new representation.

* src/callint.c (Fcall_interactively): Adjust to new representation.

* src/lread.c (bytecode_from_rev_list):

* lisp/simple.el (function-documentation):
* lisp/help.el (help-function-arglist): Remove the old `closure` case
and adjust the byte-code case so it handles `interpreted-function`s.

* lisp/emacs-lisp/cl-preloaded.el (closure): New type.
(byte-code-function): Add it as a parent.
(interpreted-function): Adjust parent (the type itself was already
added earlier by accident).

* lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Adjust to
new representation.
(byte-compile): Use `interpreted-function-p`.

* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust to
new representation.
(side-effect-free-fns): Add `interpreted-function-p` and `closurep`.

* src/profiler.c (trace_hash, ffunction_equal): Simplify.
* lisp/profiler.el (profiler-function-equal): Simplify.

* lisp/emacs-lisp/nadvice.el (advice--interactive-form-1):
Use `interpreted-function-p`; adjust to new representation; and take
advantage of the fact that function values are now self-evaluating.

* lisp/emacs-lisp/lisp-mode.el (closure):
Remove `lisp-indent-function` property.

* lisp/emacs-lisp/disass.el (disassemble-internal): Adjust to
new representation.
* lisp/emacs-lisp/edebug.el (edebug--strip-instrumentation):
Use `interpreted-function-p`.
* lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers):
Add `closurep` and `interpreted-function-p`.

* test/lisp/help-fns-tests.el (help-fns-test-lisp-defun): Adjust to
more precise type info in `describe-function`.
* test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d--render-entries):
Use `interpreted-function-p`.
* test/lisp/emacs-lisp/macroexp-resources/vk.el (vk-f4, vk-f5):
Don't hardcode function values.

* doc/lispref/functions.texi (Anonymous Functions): Don't suggest that
function values are lists.  Reword "self-quoting" to reflect the
fact that #' doesn't return the exact same object.  Update examples
with the new shape of the return value.

* doc/lispref/variables.texi (Lexical Binding):
* doc/lispref/lists.texi (Rearrangement):
* doc/lispref/control.texi (Handling Errors): Update examples to reflect
new representation of function values.
2024-04-28 11:58:12 -04:00
..
bytecomp-resources Single string literal in body is return value only, not doc string 2024-03-07 13:47:53 +01:00
edebug-resources ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
eieio-tests EIEIO: Fix regession (bug#69631) 2024-03-08 11:24:18 -05:00
ert-font-lock-resources Improve ert-font-lock assertion parser (Bug#69714) 2024-03-28 11:40:27 +02:00
faceup-resources ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
faceup-tests ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
macroexp-resources Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
package-resources ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
pp-resources Fix pp-emacs-lisp-code printing of cons cells 2022-05-17 19:45:20 +02:00
shadow-resources Use lexical-binding in most remaining emacs-lisp tests 2020-04-30 12:09:51 +02:00
testcover-resources ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
backquote-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
backtrace-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
benchmark-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
bindat-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
byte-run-tests.el ; Add 2024 to copyright years 2024-01-02 10:30:05 +08:00
bytecomp-tests.el Better format string compilation warning 2024-04-22 19:27:24 +02:00
cconv-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
check-declare-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
checkdoc-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
cl-extra-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
cl-generic-tests.el Merge from origin/emacs-29 2024-03-30 04:35:24 -04:00
cl-lib-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
cl-macs-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
cl-preloaded-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
cl-print-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
cl-seq-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
comp-cstr-tests.el * test/lisp/emacs-lisp/comp-cstr-tests.el (comp-cstr-test-93): Add test. 2024-03-19 11:05:40 +01:00
comp-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
copyright-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
derived-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
easy-mmode-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
edebug-tests.el (edebug-tests-trivial-comma): Avoid interaction (bug#69406) 2024-02-26 12:33:35 -05:00
ert-font-lock-tests.el Fix symbol list matching regexps. 2024-04-01 11:13:12 +02:00
ert-tests.el Fix ert-tests.el for the new handler-bind code 2024-01-04 16:34:13 -05:00
ert-x-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
find-func-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
float-sup-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
generator-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
gv-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
hierarchy-tests.el ; hierarchy-tests.el: keep doc string within 80 columns 2024-01-31 17:55:53 +01:00
icons-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
let-alist-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
lisp-mnt-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
lisp-mode-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
lisp-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
macroexp-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
map-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
memory-report-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
multisession-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
nadvice-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
oclosure-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
package-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
pcase-tests.el (pcase-mutually-exclusive): Use auto-generated table 2024-03-28 00:06:00 -04:00
pp-tests.el pp.el: Try and fix bug#70039 2024-03-28 15:31:04 -04:00
range-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
regexp-opt-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
ring-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
rmc-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
rx-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
seq-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
shadow-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
shortdoc-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
subr-x-tests.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
syntax-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
tabulated-list-tests.el Add tabulated-list-groups and Buffer-menu-group-by (bug#69305) 2024-02-29 19:50:04 +02:00
testcover-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
text-property-search-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
thunk-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
timer-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
track-changes-tests.el lisp/emacs-lisp/track-changes.el: New file (bug#70077) 2024-04-13 09:43:11 -04:00
unsafep-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
vtable-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
warnings-tests.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00