* module/ice-9/psyntax.scm (resolve-identifier): There is a case where a
syntax object can resolve to itself. Prevent an infinite loop in that
case by continuing to resolve by name.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syncase.test ("infinite loop bug"): Add a test.
* module/ice-9/psyntax.scm (binding-type): Update the header comment
to mention the new 'ellipsis' binding type.
(macros-only-env): Preserve ellipsis bindings.
(ellipsis?): Add 'r' and 'mod' as arguments. Search the lexical
environment for an ellipsis binding, and use it.
(gen-syntax): Adapt to the additional arguments of 'ellipsis?'.
(with-ellipsis): New core syntax.
(convert-pattern): Add unary 'ellipsis?' procedure as an argument.
(gen-clause): Adapt to the additional arguments of 'ellipsis?'.
Pass unary 'ellipsis?' procedure to 'convert-pattern'.
(syntax-case): Adapt to the additional arguments of 'ellipsis?'.
(syntax-local-binding): Support new 'ellipsis' binding type.
(syntax-rules): Add support for a custom ellipsis identifier as
the first operand, as per R7RS. Collect common code within new
local procedure 'expand-syntax-rules'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/local-eval.scm (analyze-identifiers): Add support for
'ellipsis' binding type.
* doc/ref/api-macros.texi (Syntax Rules): Add docs for R7RS custom
ellipsis syntax. Use @dots{}.
(Syntax Case): Add docs for 'with-ellipsis'. Use @dots{}.
(Syntax Transformer Helpers): Update to include new 'ellipsis'
binding type.
* test-suite/tests/syntax.test: Add tests.
* module/ice-9/psyntax.scm (expand-top-sequence): When defining a
toplevel variable, use the value of the same-named imported
_variable_, if any. Do _not_ use an existing syntactic binding.
* module/ice-9/psyntax-pp.scm: Regenerate.
Reported by taylanbayirli@gmail.com (Taylan Ulrich B.).
* module/ice-9/psyntax.scm (cvt*): Use 'syntax-case' to destructure
the pattern tail, instead of 'pair?', 'car', and 'cdr'.
(gen-clause): When checking for errors, check for misplaced ellipsis
before duplicate pattern variables, to improve the error message in
case of multiple misplaced ellipses.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add tests.
Reported by Nala Ginrut <nalaginrut@gmail.com>.
* module/ice-9/psyntax.scm (include): Give a proper error message when
given a relative file name, and when the form is not in a file.
* module/ice-9/psyntax-pp.scm: Regenerate.
* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
to push-fluid, and unwind-fluids to pop-fluid. They now only work on
one fluid binding at a time.
* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
primcalls to push-fluid and pop-fluid.
(custom-throw-handler, catch, with-throw-handler): Use with-fluid*
instead of with-fluids, as with-fluids is no longer available before
psyntax is loaded.
(with-fluids): Define in Scheme in terms of with-fluid*.
* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
don't expose to Scheme.
* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
(DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
helpers, like wind and unwind.
(memoize): Memoize wind and unwind primcalls. Don't memoize dynlet to
with-fluids.
(scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.
* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>. Add cases for
primcalls to push-fluid and pop-fluid in compile-glil.scm and
effects.scm.
* module/language/tree-il/peval.scm (peval): Factor out
with-temporaries; probably a bad idea, but works for now. Factor out
make-begin0 (a better idea). Inline primcalls to with-fluid*, and
remove dynlet cases.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
Add with-fluid*.
* ice-9/psyntax.scm (@@): Recognize new form, (@@ primitive NAME), which
in operator position expands to a primcall. This expansion is only
available for forms in the (guile) module. Added an argument to @@
and @ procedures, the module, for use by expanded syntax objects;
adapted callers.
(analyze-variable): Error when accessing a primitive for value.
(get-global-definition-hook): Primitives are not macros.
(syntax-type): A form with a primitive in the car is a
primitive-call.
(expand-expr): Residualize primitive calls as primcalls.
(syntax-local-binding): Return 'primitive as the type for primitives.
* libguile/fports.c (scm_open_file): Do not scan for coding
declarations. Replace 'use_encoding' local variable with
'binary'. Update documentation string.
* module/ice-9/psyntax.scm (include): Add the same file-encoding
logic that's used in compile-file and scm_primitive_load.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/api-io.texi (File Ports): Update docs.
* test-suite/tests/ports.test: Change "open-file HONORS file coding
declarations" test to "open-file IGNORES file coding declaration".
* test-suite/tests/coding.test (scan-coding): Use 'file-encoding' to
scan for the encoding, since 'open-input-file' no longer does so.
* module/ice-9/psyntax.scm (case-lambda, case-lambda*): Allow a
docstring to be placed immediately after the 'case-lambda' or
'case-lambda*'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/api-procedures.texi (Case-lambda): Update docs.
* test-suite/tests/optargs.test ("case-lambda", "case-lambda*"):
Add tests.
* libguile/filesys.c (scm_system_file_name_convention): New function.
Exported to Scheme only.
* module/ice-9/boot-9.scm (file-name-separator?, absolute-file-name?):
New predicates.
(file-name-separator-string): New global variable.
(in-vicinity): Use the new procedures.
(load-user-init, try-module-autoload): Use file-name-separator-string.
(load-in-vicinity): Update canonical->suffix. Consistently use the
term "file name" throughout.
* module/ice-9/psyntax.scm (include): Use global `absolute-file-name?'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (expand-body): As required by R6RS, evaluate
the right-hand-sides of internal 'define-syntax' forms and add their
transformers to the compile-time environment immediately, so that the
newly-defined keywords may be used in definition context within the
same lexical contour. Fixes#13509.
* module/ice-9/psyntax.scm (expand-body): Apply source-annotation to an
expression, not to the expression's compile-time environment.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (@): Return top-wrap instead of the wrap
applied to the '@' form, so that the symbol will be interpreted as a
top-level identifier and never refer to any lexical variable.
(@@): Change the syntax used to support R6RS 'library' forms to:
(@@ @@ (mod ...) body). Change the behavior of the documented
(@@ (mod ...) id) form to be the same as that of @, except for the use
of 'private' instead of 'public' in the psyntax mod: use syntax->datum
on the identifier, and return top-wrap instead of the wrap applied to
the '@@' form.
This fixes <http://bugs.gnu.org/10756> reported by Ludovic Courtès.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/r6rs-libraries.scm (library): Use '@@ @@' syntax instead
of the older '@@' syntax.
* test-suite/tests/syncase.test (changes to expansion environment): Use
'@@ @@' syntax.
* module/Makefile.am: Add explicit dependencies for boot-9.go on the
files that it includes: quasisyntax.scm and r6rs-libraries.scm.
* module/ice-9/psyntax.scm (do, case): Comment out these definitions,
which are never used and immediately replaced by definitions in
boot-9.scm.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/compile-psyntax.scm: Minimize syntax object literals
embedded in psyntax-pp.scm.
* module/ice-9/psyntax.scm: Rename a few variables so that syntax
objects embedded in macros have no lexical bindings, so that their
minimized syntax objects will have no embedded labels. These labels
were the last remaining gensym counters in psyntax-pp.scm.
* module/ice-9/psyntax-pp.scm: Regenerate. It is now less than one
quarter of its previous size! More importantly, this file no longer
contains any gensym counters, which means that in the future, local
changes to psyntax.scm will usually result in only local changes to
psyntax-pp.scm.
* module/language/tree-il.scm (tree-il->scheme): New implementation that
simply calls 'decompile-tree-il'.
* module/language/scheme/decompile-tree-il.scm (choose-output-names,
do-decompile): New internal procedures.
(decompile-tree-il): New and improved implementation. Print source
identifiers where possible, otherwise add minimal numeric suffixes.
Previously we printed the gensyms. Avoid 'begin' in contexts that
provide an implicit 'begin'. Produce 'cond', 'case', 'and', 'or',
'let*', named let, and internal defines where appropriate. Recognize
keyword arguments in 'opts' to disable the production of these derived
syntactic forms, and to optionally strip numeric suffixes from
variable names.
* module/ice-9/compile-psyntax.scm: Disable partial evaluation, letrec
fixing, and primitive expansion when producing psyntax-pp.scm, in
order to produce output as close to the original source as practical.
Disable production of derived syntactic forms as needed during
bootstrap. Strip numeric suffixes from variable names. Adjust
pretty-printing parameters.
* module/ice-9/psyntax-pp.scm: Regenerate. It is now less than half
of the original size.
* module/ice-9/psyntax.scm (decorate-source): Set source properties on
any object that satisfies 'supports-source-properties?'. Previously
we used 'pair?' as the predicate.
(source-annotation): Apply 'source-properties' to _any_ kind of source
expression, where previously only pairs were queried. If the argument
is a syntax-object, apply the source-properties to the syntax-object's
expression.
In the peculiar case of a syntax-object whose expression is also a
syntax-object: previously we would iterate, but with this commit we
now call 'syntax-object-expression' only once.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (syntax-violation): Look for source
properties of 'subform' first. If 'subform' has none, 'form' is used.
Previously, the source information of 'form' was used unless 'form'
_itself_ was '#f', in which case 'subform' was used.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (rebuild-macro-output): Fix two bugs that
would cause bogus source properties to be added to vectors and
macro-introduced syntax objects. These bugs were masked by the
limitation that only pairs can be decorated with source properties.
Due to a typo, each vector in the macro output was decorated using the
vector itself as its source. Due to accidental variable capture, each
syntax-object introduced by the macro had its expression decorated
with its own wrap-subst.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (syntax-type): Return an additional value
that contains the entire form in _all_ cases, including for definition
forms. Previously, the entire form was not returned for definition
forms.
(expand-expr): Add an additional argument that contains the entire
form in _all_ cases, including for definition forms. Use it to
include the entire form in error messages, notably for definitions in
expression context. Include the source location information, which
was previously missing from these errors when the rhs expression was
an atom. Improve the "definition in expression context" error message
to be more comprehensible for Scheme beginners.
(expand-top-sequence, expand, expand-body): Adjust as needed to handle
the additional return value from 'syntax-type' and the additional
argument to 'expand-expr'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* NEWS: Update.
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (dynamic-wind): When you make a
gensym that just has to be compared against other gensyms, it will be
unique if the prefix doesn't end in something that can be interpreted
as a number. There's no reason to make that character something
difficult like " ". So change to use a dash in that case.
* module/ice-9/psyntax-pp.scm: Regenerate. More readable now.
* libguile/macros.c (scm_init_macros): Add definition of new
syntax-session-id helper.
* module/ice-9/psyntax.scm: Capture a reference to syntax-session-id at
boot time. Uniquify marks and labels using the session id.
* module/ice-9/boot-9.scm: Shunt syntax-session-id off to (system
syntax) once we finished booting.
* module/ice-9/compile-psyntax.scm: Override syntax-session-id when
remaking psyntax to avoid spurious diffs.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/boot-9.scm:
* module/ice-9/psyntax.scm (syntax-module, syntax-local-binding)
(syntax-locally-bound-identifiers): After boot, move these definitions
to a new (system syntax) module.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/api-macros.texi: Add some words about syntax-module and
friends being in (system syntax).
* 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.