* module/ice-9/psyntax.scm (free-id=?): For identifiers that are
resolved to the toplevel, check that the variables that they would
resolve to are equal, instead of simply checking that the symbolic
identifier names are equal. Allows keywords to be bound, renamed,
exported, excluded, etc.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (chi-when-list): Just match symbolically
instead of lexically, so as not to tie the meaning of eval-when to the
bindings of eval, load, compile, and expand.
* module/ice-9/psyntax.scm (fx+, fx-, fx=, fx<): Given our lame lack of
an inliner, inline these manually with identifier syntax.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (with-syntax): Allow definitions in the body,
as seems to be suggested by the R6RS.
* test-suite/tests/syncase.test ("with-syntax"): Add test.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (chi-top-sequence): Manually inline
eval-if-c&e into its two call sites; I found it hard to understand
otherwise. If the mode is just 'e, defer expansion of definitions and
expressions until the end, so that they can be expanded in a context
of all syntax expanders defined in the sequence.
* module/ice-9/psyntax.scm (chi-top-sequence): Pull chi-top into the
body of this toplevel begin expander. This will let us do r6rs
toplevel expansion correctly.
(chi-top): Remove.
(macroexpand): Dispatch to chi-top-sequence directly.
* module/ice-9/psyntax.scm (quasiquote): Import new definition from
upstream psyntax, to allow unquote and unquote-splicing to take
multiple arguments.
(unquote, unquote-splicing): Adapt to not require a particular syntax
form.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (chi-top): When adding to the toplevel
environment at compile-time, default to undefined variables, not
variables defined to #f.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/boot-9.scm (module-add!): Add a new pre-modules version
of this function, so we can add variables the environment, not just
values.
(module-define!): Use module-add!.
* module/ice-9/psyntax.scm (syntax-violation): Use lambda* for subform
arg. Instead of using scm-error, just throw to 'syntax-error with all
we got.
* module/ice-9/psyntax-pp.scm (#{and-map*\ 37}): Regenerated.
* libguile/vm-i-scheme.c (symbol?, vector?): New
instructions. Renumbered the rest.
* libguile/vm-i-system.c: Renumber instructions.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* module/ice-9/psyntax.scm (binding-type, binding-value): Define using
macros so that we inline to car and cdr opcodes. Oh, for an inliner :)
* module/language/tree-il/compile-glil.scm (*primcall-ops*)
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*, *effect-free-primitives*)
(*effect+exception-free-primitives*): Add symbol? and vector?
inlines.
* module/ice-9/psyntax.scm (lookup): Reflow comment.
(chi-top, syntax): Add comments about mod for lookup.
(set!): Lookup the identifier in the module attached to its syntax
object. In the (set! MACRO foo) case, after expanding the macro, chi
the resulting expression with the empty wrap, as syntax-type
does. Seems to fix the case where the expansion references
lexically-bound variables.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syncase.test: Add a bunch of tests.
* module/ice-9/psyntax.scm (underscore?): New helper, like ellipsis?.
(syntax-case): Treat the _ pattern as a matches-all pattern,
disallowing it from the keyword list. Another well-thought part of the
R6RS.
($sc-dispatch): Dispatch _ patterns.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syncase.test ("_ is a placeholder"): Add a test.
* module/ice-9/psyntax.scm (build-lexical-assignment)
(build-global-assignment): Maybe name the RHS.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/boot-9.scm (catch, with-throw-handler, throw): Rework to
use set! instead of define! so that we get names.
* module/ice-9/psyntax.scm (set!): Handle variable transformers; though,
they cannot produce definitions.
(make-variable-transformer): New procedure.
(identifier-syntax): Allow the R6RS form that makes variable
transformers.
* module/ice-9/psyntax-pp.scm: Regenerated.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Remove letrec* item, and
add set! restriction.
* module/ice-9/psyntax.scm (chi-body): Whoops, actually render internal
definitions into a letrec* in the right order.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add some letrec* tests.
* module/ice-9/psyntax.scm (chi-body): Internal definitions are now
letrec* instead of letrec, following the R6RS.
* module/ice-9/psyntax-pp.scm: Regenerated.
* libguile/expand.c (expand_letrec_helper): Factor out common code.
(expand_letrec): Use expand_letrec_helper.
(expand_letrec_star): New primitive syntax: letrec*.
* libguile/memoize.c (memoize): Add memoizer support for in-order letrec
(letrec*).
* module/ice-9/psyntax.scm (build-letrec): Another arg, `in-order?'.
(chi-body): Adapt to build-letrec change. We don't yet use letrec* for
internal definitions.
(letrec): Adapt to build-letrec change.
(letrec*): New expander.
* module/ice-9/psyntax-pp.scm: Regenerated.
* libguile/expand.h (SCM_EXPANDED_LETREC_IN_ORDER_P)
(SCM_MAKE_EXPANDED_LETREC): Add a new field to letrec, in-order?. Will
be used to support letrec*.
* libguile/expand.c (LETREC, expand_named_let, expand_letrec): Adapt
code.
* module/language/elisp/compile-tree-il.scm (compile-pair):
* module/ice-9/psyntax.scm (build-named-let, build-letrec): Pass #f for
in-order? to `make-letrec'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/language/tree-il.scm: Add letrec-in-order? accessor.
(parse-tree-il, unparse-tree-il): Parse and unparse an in-order?
letrec as `letrec*'.
(tree-il->scheme): Serialize letrec*.
* module/ice-9/psyntax.scm: Fix bug in which the whole syntax object was
being recorded as the name of the operator in a lexical call, instead
of just the symbolic name.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (chi-install-global, chi-macro)
(eval-local-transformer): Now that we handle module hygiene through
syntax objects, there is no more need to record the current module
when installing syntax transformers.
* module/ice-9/psyntax-pp.scm: Regenerated (trickily).
* libguile/_scm.h: Bump objcode version for macro representation change.
* libguile/macros.c (scm_macro_transformer): Adapt to change in macro
representation.
* module/ice-9/psyntax.scm (chi-macro): Instead of assuming that output
of a macro should be scoped relative to the module that was current
when the macro was defined, allow the module information associated
with the syntax object itself to pass through unmolested. Fixes bug
29860.
(datum->syntax): Propagate the module of the identifier through to the
new syntax object, so that datum->syntax preserves module hygiene in
addition to lexical hygiene.
(include, include-from-path): Refactor to plumb though the hygiene
information from the filename instead of the `include', allowing
hygiene from the original caller of include-from-path to propagate
through.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syncase.test ("macro-generating macro"): Add test for
bug 29860.
* module/ice-9/psyntax.scm (syntax-type): Add some comments about source
locations. In calls to chi-macro, pass the source location
information. Propagate source location information when unpacking
syntax objects.
(chi-macro): Add a comment about source locations. Decorate output
introduced by the macro with the source location of macro use.
* module/ice-9/psyntax-pp.scm: Regenerate.
Fixes bug #29817.
* module/ice-9/psyntax.scm (define-expansion-accessors): New helper, to
define accesors for a particular expansion data structure. Use it
later to define lambda?, lambda-meta, and set-lambda-meta!.
(maybe-name-value): Update to work with the newly defined accessors.
(build-global-reference, build-let, build-named-let, build-letrec):
Re-enable naming of procedures.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm: Remove the *mode* fluid. Whee :)
(macroexpand): No need to bind aa *mode* fluid.
* module/ice-9/psyntax-pp.scm: Regenerated.
* libguile/expand.c (expand_lambda_star_case): Harmonize with tree-il,
expanding keywords to (aok? (kw name gensym) ...), not
(aok? (kw . index) ...).
* libguile/memoize.c (memoize): Process the (kw name gensym) format into
(kw . index).
* module/ice-9/psyntax.scm (build-lambda-case): Remove a
compile-versus-eval special case.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/eval.scm (primitive-eval):
* libguile/eval.c (scm_c_primitive_eval): Don't expect a memoized
expression -- expect either raw source or an *expanded* expression. We
handle memoization ourselves.
* libguile/expand.c (scm_macroexpand): Settle down into its proper name,
"macroexpand", even as we comment that it is but a fleeting boot
expander.
(scm_macroexpanded_p): New predicate for expanded code.
* libguile/expand.h: Add scm_macroexpanded_p.
* libguile/memoize.c (scm_memoize_expression): Require that the
expression be expanded.
(scm_init_memoize): Don't alias memoize-expression to macroexpand.
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm: Always produce macroexpanded expressions,
and hand them to primitive-eval. No more calls to memoize-expression
here.
* test-suite/tests/optargs.test: Remove some tests, as unfortunately we
have no way to invoke the boot expander after boot.
* module/ice-9/psyntax.scm: Remove a number of eval-versus-compile
cases, instead producing "expanded" structures directly, which happen
to coincide with tree-il.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (build-case-lambda, build-lambda-case):
Actually build case-lambda expressions, knowing that the memoizer will
do the right thing.
* module/ice-9/psyntax-pp.scm: Regenerated.
* libguile/eval.c (scm_c_primitive_eval):
* module/ice-9/eval.scm (primitive-eval): Rely on the expander to
produce a memoized expression. If the expression is already memoized,
just pass it through (the equivalent of the old "noexpand" hack).
* libguile/memoize.c (scm_init_memoize): Initialize `memoize-expression'
as the initial binding of `macroexpand'.
* libguile/modules.c (scm_module_transformer): Before modules are
booted, look for `macroexpand', not `%pre-modules-transformer'.
* module/ice-9/boot-9.scm: No more %pre-modules-transformer. Loading
psyntax extends `macroexpand'.
(make-module): `macroexpand' is the default transformer.
* module/ice-9/psyntax.scm: No more `noexpand'.
(top-level-eval-hook, local-eval-hook): Instead of annotating with
noexpand, memoize the expression before handing it to primitive-eval.
(macroexpand): No more noexpand hack -- in its place we have another
hack, to memoize the result when running in eval mode.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm: Revert tracking of the current module while
expanding toplevel sequences. Better to preserve lexical scoping
(relative to the module of the original expression) and allow for @@
to override it.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syncase.test: Test module-changing with @@.
* module/ice-9/psyntax.scm (@@): The RHS of an @@ is no longer
restricted to be an identifier, it can be an arbitrary expression.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (chi-when-list, chi-top): Add an undocumented
`expand' situation to eval-when, which will trigger at expand-time for
toplevel expressions. Useful when you are expanding for eval, but need
to do some side effect to affect the expander -- like defining a
module.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (chi-top): Only modify the compile-time
environment to indicate that there is a local binding if we are
running in compile mode. Otherwise some eval-when things might not
have gotten executed, and our current-module could be wrong.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (syntax-rules, identifier-syntax):
* module/ice-9/boot-9.scm (define-macro): Embed metadata into the macro
transformer for use by documentation tools and the like.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (chi-lambda-case, lambda): If we find a
vector of pairs in the docstring position, interpret those pairs as
additional metadata.
* module/ice-9/psytntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (build-simple-lambda, build-case-lambda):
Don't take a docstring, take a metadata alist. Don't bother annotating
interpreted expressions with docstrings.
(chi-simple-lambda): Take already-parsed metadata.
(lambda): Parse out multiple docstrings as separate "documentation"
entries in the "meta".
(chi-lambda-case): Merge multiple "meta" entries among the various
cases.
(lambda*, case-lambda, case-lambda*): Receive "meta" clauses, not
docstrings.
* module/ice-9/psyntax-pp.scm: Regenerated.