* module/ice-9/boot-9.scm (syntax-local-binding): New binding.
* module/ice-9/psyntax.scm: Locally define a fluid that holds the
"transformer environment". with-transformer-environment calls a
procedure with the transformer environment, or raises an error if
called outside the extent of a transformer. Bind
transformer-environment in expand-macro.
(resolve-identifier): Backport this helper from master.
(syntax-local-binding): New procedure to return binding information of
a bound identifier (a lexical, macro, a pattern variable, a displaced
lexical, a global, or some other form).
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/api-macros.texi (Syntax Transformer Helpers): Add docs for
syntax-local-binding, and syntax-source, and move some other
descriptions to this new section.
* 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.
Conflicts:
module/ice-9/psyntax.scm
* module/ice-9/psyntax.scm (define-expansion-constructors)[begin-form]:
Emit a syntax-violation error for empty sequences when
--disable-deprecated.
* test-suite/tests/syntax.test (pass-if-syntax-error): Fix typo in error
message.
* doc/ref/api-control.texi (begin): Update to distinguish between
splicing begin and sequencing begin.
* module/ice-9/psyntax.scm (expand-expr): Add a back-compatibility shim
for `(begin)'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Update to run illegal (begin) test only
if we are not including deprecated features.
* module/ice-9/psyntax.scm: Rename expand-when-list to parse-when-list,
and simplify to compare literal values.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm: Rename all instances of "chi" to "expand".
Addded a hack to expand-eval-when that will be fixed later.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm (chi-top-sequence): Detect bindings to
identifiers introduced by macros. In that case, in order to preserve
hygiene, uniquify the variable's name, but in a way that is
reproduceable (i.e., yields the same uniquified name after a
recompile).
* module/ice-9/psyntax.scm (id-var-name): For mapping identifiers to
toplevel definitions, also compare against the module.
(resolve-identifier): Pass the module to id-var-name when looking up
identifiers.
(free-id=?): Adapt to id-var-name change.
(chi-top-sequence): When adding a mapping from the given identifier
to a toplevel definition, make the name be a pair.
* module/ice-9/psyntax.scm (resolve-identifier): Take an additional
argument, indicating whether syntax parameters should be resolved or
not. Just return three values: the binding type and value, and the
module for resolving toplevels.
(chi-install-global): Take an extra arg, the type. If we are defining
a syntax parameter, construct a pair for the binding.
(chi-body): Syntax parameters now use a per-parameter unique value (a
pair) as a key in the expansion-time environment `r'.
(syntax-parameterize): Don't allow parameterization of
non-parameters. This is an incompatible change, but it is for the
better; you don't want to allow users to parameterize `lambda', after
all.
* 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.