* module/ice-9/psyntax.scm (define-syntax-parameter): New toplevel form.
Will be used to implement syntax parameters, following Barzilay,
Culpepper, and Flatt's 2011 SFP workshop paper, "Keeping it Clean with
syntax-parameterize". Adds a new binding type and definition form.
* module/ice-9/psyntax.scm (id-var-name): Add a nice long comment.
(lookup): Remove, as it is no longer used.
(resolve-identifier): New helper, replaces most uses of id-var-name
then `lookup'.
(syntax-type, syntax, set!, fluid-let-syntax): Adapt to use
resolve-identifier.
(free-id=?): Adapt to id-var-name returning syntax objects.
* module/ice-9/psyntax.scm (chi-top-sequence): Reimplement, more like
chi-body. Instead of adding empty definitions to the toplevel, add
toplevel definitions to the wrap shared by all forms in the sequence.
This was a pretty big merge involving a fair amount of porting,
especially to peval and its tests. I did not update psyntax-pp.scm,
that comes in the next commit.
Conflicts:
module/ice-9/boot-9.scm
module/ice-9/psyntax-pp.scm
module/language/ecmascript/compile-tree-il.scm
module/language/tree-il.scm
module/language/tree-il/analyze.scm
module/language/tree-il/inline.scm
test-suite/tests/tree-il.test
* module/ice-9/psyntax.scm (define-syntax-rule): Add this new helper
macro, to define a syntax-rules macro with one clause.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (syntax-case): enabled the use of a
general last cdr instead of just '() in matching with both
a ellipsis (p ...) and a last rest pattern (. q)
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (generate-temporaries): Give temporaries the
current module, so that they may be bound at the top level.
* module/ice-9/psyntax-pp.scm: Regenerate.
* 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/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.