* module/language/elisp/boot.el (lexical-let, lexical-let*): New macros.
* module/language/elisp/compile-tree-il.scm (bind-lexically?): Remove
the check for a `lexical' flag, since `lexical-let' and `lexical-let*'
are no longer special operators.
(compile-lexical-let, compile-lexical-let*): Remove.
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
* module/language/elisp/boot.el (null, consp, listp, car, cdr)
(make-symbol, signal): Use `%funcall' instead of `funcall' or `fset'.
(symbolp, symbol-function, eval): Use `%funcall', since `funcall' now
calls these functions.
(functionp, %indirect-function): New functions.
(funcall): Define in terms of `%funcall' and `%indirect-function'.
(apply): New function. Previously defined in
"module/language/elisp/runtime/subrs.scm".
(fset): If `definition' is not a function, set the function cell of
`symbol' to an falias for `definition'.
* module/language/elisp/falias.scm: New file.
* module/language/elisp/subrs.scm: Remove file.
(apply): Remove. Now defined in "boot.el".
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
* module/Makefile.am: Update.
* module/language/elisp/compile-tree-il.scm: (always-lexical): Remove.
All uses changed.
(with-added-symbols): Remove.
(compile-with-always-lexical): Remove.
(process-options!): Remove support for the `#:always-lexical' option.
* module/language/elisp/runtime/function-slot.scm: Update import and
re-export lists.
* test-suite/tests/elisp-compiler.test: Remove or update tests using
`with-always-lexical'.
* module/language/elisp/bindings.scm (global?): New function.
* module/language/elisp/compile-tree-il.scm (lexical-binding): New
variable.
(bind-lexically?): If lexical binding is enabled, bind lexically
unless a special binding exists.
(compile-%set-lexical-binding-mode): New function.
* module/language/elisp/lexer.scm (lexical-binding-regexp): New
variable.
(lex): Return a `set-lexical-binding-mode!' token if a comment is
found while reading the first line.
* module/language/elisp/parser.scm (get-expression): Add support for
`set-lexical-binding-mode!' tokens.
* module/language/elisp/runtime/function-slot.scm: Import and re-export
the `%set-lexical-binding-mode' special form.
* test-suite/tests/elisp-compiler.test
("Let and Let*")["lambda args inside lexical-let"]: Update.
* module/language/elisp/runtime/macros.scm: Remove.
(macro-lambda, macro-prog1, macro-prog2, macro-cond, macro-and,
macro-or, macro-catch, macro-unwind-protect): Rewrite in Elisp and
move to...
* module/language/elisp/boot.el (lambda, prog1, prog2, cond, and, or,
catch, unwind-protect): ...here.
(eval-and-compile): New macro.
(funcall, fset, null, consp, listp, car, cdr, make-symbol-signal):
Wrap definitions in an `eval-and-compile' form so that they can be
used by the rewritten macros.
* module/language/elisp/runtime.scm: Remove `built-in-macro'.
* module/language/elisp/Makefile.am: Remove
module/language/elisp/runtime/macros.scm from `ELISP_LANG_SOURCES'.
* module/language/elisp/compile-tree-il.scm (access-variable)
(reference-variable, set-variable!): Handle globally-bound non-special
variables.
(bind-lexically?): Create lexical bindings for flet and flet*.
* module/language/elisp/runtime.scm (reference-variable, set-variable!):
Handle globally-bound non-special variables.
(built-in-func): Set the variable directly instead of storing the
function in a fluid.
* module/language/elisp/runtime/subrs.scm (funcall): Call apply
directly.
* test-suite/tests/elisp-compiler.test ("Function Definitions")["flet
and flet*"]:
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/compile-tree-il.scm (reference-with-check)
(compile-without-void-checks, want-void-check?): Remove.
(compile-function, compile-pair): Use `reference-variable' instead of
`reference-with-check'.
(compile-defvar): Only set `sym' if `sym' is not bound to a bound
fluid, rather than requiring that its value be `void'.
(process-options!): Remove `#:disable-void-check' option handling.
* module/language/elisp/runtime.scm (void)
(reference-variable-with-check): Remove.
(ensure-fluid!): Use an undefined fluid as the initial value for
global variables.
* module/language/elisp/runtime/function-slot.scm (without-void-checks):
Don't import or re-export.
* module/language/elisp/runtime/macros.scm (prog1, cond, or, dolist):
Don't use `without-void-checks'.
* module/language/elisp/runtime/subrs.scm (symbol-value)
(symbol-function, apply): Use `reference-variable' instead of
`reference-variable-with-check'.
(makunbound, fmakunbound, boundp, fboundp): Unset the variable's fluid
(or the variable itself, if it isn't bound to a fluid).
* test-suite/tests/elisp-compiler.test ("Variable
Setting/Referencing")["disabled void check (all)", "disabled void
check (symbol list)", "without-void-checks"]: Remove.
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/runtime/subrs.scm (setcar, setcdr): Allow
setting the car or cdr of `nil' to `nil'.
Signed-off-by: Andy Wingo <wingo@pobox.com>
Use #{`}#, #{,}# and #{,@}# as the quasiquote, unquote and
unquote-splicing operators, respectively. Previously they were named
escaping.
* module/language/elisp/compile-tree-il.scm (unquote?): Change "\," to
"#{,}#".
(unquote-splicing): Change "\,@" to "#{,@}#".
(#{compile-`}#): Rename from #{compile-\`}#.
* module/language/elisp/runtime/function-slot.scm: Import #{compile-`}#
instead of #{compile-\`}#, and re-export as #{`}# instead of as
#{\`}#.
* module/language/elisp/parser.scm (quotation-symbols):
* test-suite/tests/elisp-compiler.test ("Eval", "Quotation"):
* test-suite/tests/elisp-reader.test ("Parser"): Change "\`", "\,", and
"\,@" to "#{`}#", "#{,}#" and "#{,@}#", respectively.
If the function slot of a symbol contains a pair with `special-operator'
in the car and a procedure in the cdr, the procedure is called to
compile the form to Tree-IL. This is similar to other Emacs Lisp
implementations, in which special operators are subrs.
* module/language/elisp/compile-tree-il.scm: Restructured to store
special operator definitions in the function slot. Import `(language
elisp runtime)' for `defspecial'. Export special operators so that
`(language elisp runtime function-slot)' can re-export them.
(backquote?): Removed; the backquote symbol is defined as a special
operator, so it's no longer used in `compile-pair'.
(is-macro?, get-macro): Replaced by `find-operator'.
(find-operator): New procedure.
(compile-progn, compile-if, compile-defconst, compile-defvar,
compile-setq, compile-let, compile-lexical-let, compile-flet,
compile-let*, compile-lexical-let*, compile-flet*,
compile-without-void-checks, compile-with-always-lexical,
compile-guile-ref, compile-guile-primitive, compile-while,
compile-function, compile-defmacro, compile-defun, #{compile-`}#,
compile-quote): New special operators with definitions taken from the
pmatch form in `compile-pair'. There is no special operator `lambda';
it is now a macro, as in other Elisp implementations.
(compile-pair): Instead of directly compiling special forms, check for
a special operator object in the function slot.
* module/language/elisp/runtime.scm: Export `defspecial'.
(make-id): New function.
(built-in-macro): Prefix macros with `macro-'.
(defspecial): New syntax.
* module/language/elisp/runtime/function-slot.scm: Import and re-export
special operators. Rename imported special operators and macros to
remove prefixes. Re-export new macro `lambda'.
* module/language/elisp/runtime/macros.scm (macro-lambda): New Elisp
macro.
Guile Emacs Lisp previously kept macros in a separate macro slot; now
macros are stored as macro objects in the function slot for
compatibility with other implementations.
* module/language/elisp/compile-tree-il.scm (macro-slot): Remove.
(is-macro?): Check that the argument is a symbol. Now-unnecessary
check removed in `compile-tree-il'.
(macro?, define-macro!, get-macro): Store macro definitions in the
function slot, not in a separate macro slot.
* module/language/elisp/runtime.scm (built-in-macro): Wrap the macro
function in a macro object (i.e., cons the symbol `macro' onto it).
* module/language/elisp/runtime/function-slot.scm: Move contents to
"subrs.scm". Re-export function and macro definitions instead of
defining functions directly in this module.
* module/language/elisp/runtime/macro-slot.scm: Move contents to
"macros.scm" and remove.
* module/language/elisp/runtime/macros.scm: New file containing macro
definitions from "macro-slot.scm".
* module/language/elisp/runtime/subrs.scm: New file containing function
definitions from "function-slot.scm".
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm: Ensure that all
top-level forms and comments are separated by exactly one newline.
Remove blank lines in most procedure bodies. Delete trailing
whitespace.
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/runtime/macro-slot.scm (or, and): Fix one-arg
case to return the arg as-is.
* module/language/elisp/runtime.scm (nil-value): Fix to be #nil.
* module/language/elisp/README: Document new features.
* module/language/elisp/runtime/function-slot.scm: Implement funcall, apply and
eval by using the existing compiler code.
* test-suite/tests/elisp-compiler.test: Test those.
* module/language/elisp/README: Document it.
* module/language/elisp/compile-tree-il.scm: Moved ensure-fluid! to runtime function.
* module/language/elisp/runtime.scm: Runtime functions to support dynamic value access.
* module/language/elisp/runtime/function-slot.scm: Defined the built-ins.
* test-suite/tests/elisp-compiler.test: Test them.
* module/language/elisp/README: Document it and some further ideas written down.
* module/language/elisp/compile-tree-il.scm: Implement prog1, dolist.
* module/language/elisp/runtime/macro-slot.scm: prog2 and dotimes.
* test-suite/tests/elisp-compiler.test: Test prog1, prog2, dotimes, dolist.
* module/language/elisp/README: Document it.
* module/language/elisp/compile-tree-il.scm: Implement defmacro and expansion.
* module/language/elisp/runtime/macro-slot.scm: New module to keep definitions.
* test-suite/Makefile.am: Add elisp-compiler.test to list of tests.
* test-suite/tests/elisp-compiler.test: Basic macro tests.
* module/language/elisp/runtime/function-slot.scm: Fixed errors in number preds.
* test-suite/tests/elisp-compiler.test: Test built-ins already implemented.