* 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/bindings.scm: Use `(srfi srfi-9)'.
(bindings-type): Remove low-level record type definition and replace
with...
(bindings): ...this, an SRFI-9 record type. All uses changed.
(mark-global-needed!): Rename to...
(mark-global!): ...this. All callers changed.
(map-globals-needed): Rename to...
(map-globals): ...this. All callers changed.
* module/language/elisp/compile-tree-il.scm (generate-let)
(generate-let*, compile-lambda, compile-with-added-symbols)
(compile-progn, compile-if): Return nil if the form's body is empty.
* test-suite/tests/elisp-compiler.test ("Sequencing")["empty progn"]:
New test.
("Conditionals")["if with no else"]: New test.
("Let and Let*")["empty let, empty let*"]: New test.
("Lambda Expressions")["empty lambda"]: New test.
* 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'.
* libguile/expand.h:
* module/language/tree-il.scm: Rename "sequence" to "seq", and instead
of taking a list of expressions, take a head and a tail.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/spec.scm:
* module/language/elisp/compile-tree-il.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/eval.scm:
* libguile/memoize.h:
* libguile/memoize.c:
* libguile/expand.c:
* libguile/eval.c: Adapt to the new seq format.
* 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/compile-tree-il.scm (compile-function): the form
`(function SYMBOL)' evaluates to the functional value of SYMBOL
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>
* module/language/elisp/lexer.scm (lex):
* module/language/elisp/parser.scm (get-expression): Support sharpsign
single-quote syntax as an abbreviation for `function' expressions.
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/compile-tree-il.scm (compile-setq): Return nil
if called with no arguments, and set the last variable to nil if its
value is omitted.
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.
* module/language/elisp/compile-tree-il.scm (ensuring-globals): New
procedure.
(define-macro!): Remove.
(compile-pair) <defmacro>: Make macro available at runtime, not only
during compilation.
(compile-tree-il): Use `ensuring-globals'.
* module/language/elisp/lexer.scm (lex, get-lexer/1): Return a valid
token at EOF.
* module/language/elisp/parser.scm (get-expression): Raise an error if
EOF is reached.
(read-elisp): If at EOF, return the EOF object instead of attempting
to read an expression.
Signed-off-by: Andy Wingo <wingo@pobox.com>
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/compile-tree-il.scm (compile-lambda): Use
Tree-IL's support for optional arguments.
(process-optionals, process-rest): Remove.
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>