emacs/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
..
advice.el * lisp/emacs-lisp/advice.el (comp-subr-trampoline-install): Don't declare. 2024-03-15 14:43:40 +01:00
avl-tree.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
backquote.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
backtrace.el (backtrace--print-func-and-args): Fix (part of) bug#70436 2024-04-20 11:23:58 -04:00
benchmark.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
bindat.el * lisp/emacs-lisp/bindat.el (sint): Burp in dynbind (bug#69749) 2024-03-15 12:45:09 -04:00
byte-opt.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
byte-run.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
bytecomp.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
cconv.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
chart.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
check-declare.el Do not attempt to check declarations in lock files 2024-02-20 22:49:07 +01:00
checkdoc.el ; Simplify (with-current-buffer (get-buffer ...) ...) 2024-03-14 12:40:26 +02:00
cl-extra.el (cl--describe-class-slots): Avoid cryptic t type 2024-04-09 18:33:01 -04:00
cl-generic.el cl-preloaded.el: Fix the type lattice 2024-03-26 13:14:15 -04:00
cl-indent.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
cl-lib.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
cl-macs.el (cl-defstruct): Improve handling of unknown options 2024-04-16 21:17:47 -04:00
cl-preloaded.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
cl-print.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
cl-seq.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
comp-common.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
comp-cstr.el * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): Improve last change. 2024-04-10 18:45:47 +02:00
comp-run.el ; * lisp/emacs-lisp/comp-run.el (comp-run-async-workers): Fix indentation. 2024-03-20 16:59:33 +01:00
comp.el * lisp/emacs-lisp/comp.el (comp--add-cond-cstrs): Consolidate 2 cases 2024-03-29 15:36:45 -04:00
compat.el Add the public API of Compat to the core 2024-02-11 22:50:29 +01:00
copyright.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
crm.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
cursor-sensor.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
debug-early.el (backtrace-on-redisplay-error): Use handler-bind 2024-01-04 16:37:01 -05:00
debug.el debug.el: Prevent re-entering the debugger for the same error 2024-03-16 23:10:48 -04:00
derived.el derived.el: Delete old code (bug#68625) 2024-01-29 19:04:59 -05:00
disass.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
easy-mmode.el Refine the Custom type of generated '*-modes' options 2024-04-27 17:18:31 +02:00
easymenu.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
edebug.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
eieio-base.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
eieio-core.el (cl-type-of): New function to return more precise types (bug#69739) 2024-03-18 09:29:47 -04:00
eieio-custom.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
eieio-datadebug.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
eieio-opt.el ; Simplify (with-current-buffer (get-buffer ...) ...) 2024-03-14 12:40:26 +02:00
eieio-speedbar.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
eieio.el eieio-core.el: Always put a parent in the parents of a class 2024-03-08 02:04:59 -05:00
eldoc.el Use obarray-make instead of make-vector to create obarrays 2024-02-23 13:02:27 +01:00
elint.el Take file-local variables into account in elint-file (bug#69076) 2024-02-14 08:54:04 +01:00
elp.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
ert-font-lock.el Fix symbol list matching regexps. 2024-04-01 11:13:12 +02:00
ert-x.el Complete change of ert-remote-temporary-file-directory 2024-01-06 18:15:23 +01:00
ert.el ert.el: Use handler-bind to record backtraces 2024-01-04 16:33:25 -05:00
ewoc.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
faceup.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
find-func.el Make find-function-regexp also find transient-define-* 2024-02-20 13:58:32 +01:00
float-sup.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
generate-lisp-file.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
generator.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
generic.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
gv.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
helper.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
hierarchy.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
icons.el * lisp/emacs-lisp/icons.el (define-icon): Add 'doc-string' to 'declare'. 2024-04-17 21:01:14 +03:00
inline.el * lisp/emacs-lisp/inline.el (inline-const-val): Improve docstring 2024-01-30 13:14:32 -05:00
let-alist.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
lisp-mnt.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
lisp-mode.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
lisp.el * lisp/emacs-lisp/lisp.el (forward-sexp-function): Set back to nil. 2024-04-17 09:53:02 +03:00
loaddefs-gen.el Allow trivially autoloading uses of transient's define macros 2024-02-20 22:04:51 +01:00
macroexp.el ; * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): less consing 2024-04-14 11:51:17 +02:00
map-ynp.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
map.el * lisp/emacs-lisp/map.el (map--make-pcase-bindings): Fix use in Emacs<30 2024-02-21 08:49:15 -05:00
memory-report.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
multisession.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
nadvice.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
oclosure.el Use a dedicated type to represent interpreted-function values 2024-04-28 11:58:12 -04:00
package-vc.el Always update VC packages from a vc-dir buffer 2024-04-26 08:21:37 +02:00
package-x.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
package.el Improve documentation of 'package-enable-at-startup' 2024-04-27 11:52:30 +03:00
pcase.el ; * lisp/emacs-lisp/pcase.el (pcase--subtype-bitsets): Doc fix. 2024-03-28 11:34:25 +02:00
pp.el Propagate 'lexical-binding' value to pp buffers 2024-04-17 17:02:11 -04:00
radix-tree.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
range.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
re-builder.el ; Simplify (with-current-buffer (get-buffer ...) ...) 2024-03-14 12:40:26 +02:00
regexp-opt.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
regi.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
ring.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
rmc.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
rx.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
seq.el Followup changes to cl-type-of 2024-03-18 09:32:53 -04:00
shadow.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
shortdoc.el ; * lisp/vc/vc-git.el (vc-git--out-str): Doc fix. 2024-03-18 15:59:54 +02:00
shorthands.el Improve shorthands-font-lock-shorthands (bug#67390) 2024-02-03 08:40:03 -06:00
smie.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
subr-x.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
syntax.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
tabulated-list.el Add tabulated-list-groups and Buffer-menu-group-by (bug#69305) 2024-02-29 19:50:04 +02:00
tcover-ses.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
testcover.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
text-property-search.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
thunk.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
timer-list.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
timer.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
tq.el ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
trace.el Merge from origin/emacs-29 2024-02-10 05:07:56 -05:00
track-changes.el (track-changes--call-signal): Silence late signals 2024-04-19 22:19:00 -04:00
unsafep.el Merge from savannah/emacs-29 2024-01-02 10:28:14 +08:00
vtable.el 'vtable-update-object' can now be called with one argument 2024-03-21 12:41:44 +02:00
warnings.el * lisp/emacs-lisp/warnings.el (warning-display-at-bottom): New defcustom. 2024-04-22 09:50:45 +03:00