* module/ice-9/syncase.scm: Export datum->syntax-object and
syntax-object->datum as aliases of datum->syntax and syntax->datum.
Thanks to Daniel Llorens del Río for the suggestion.
* module/ice-9/boot-9.scm
(eval-when): Remove, as syncase is going to handle this one for us.
(sc-expand, sc-expand3, sc-chi, install-global-transformer)
(syntax-dispatch, syntax-error, annotation?, bound-identifier=?)
(datum->syntax-object, free-identifier=?, generate-temporaries)
(identifier?, syntax-object->datum, void, andmap): Oh, ugly of uglies:
add these exciting definitions to the main environment. Hopefully we
can pull them back out soon.
(make-module-ref, resolve-module): Stub these out, as a replacement for
expand-support.
(%pre-modules-transformer): Define to sc-expand, so that we are using
syncase from the very start.
(defmacro, define-macro): Define in terms of syntax-case.
(macroexpand, macroexpand-1): Remove, there should be a different way
to get at this -- though perhaps with the same name.
(make-module): Make sc-expand the default module-transformer.
(process-define-module): Issue a deprecation warning when using ice-9
syncase.
(primitive-macro?): Remove, no meaning...
(use-syntax): Deprecate.
(define-private, define-public, defmacro-public): Rework in terms of
syntax-rules.
* module/ice-9/syncase.scm: Gut, as syncase is provided by core now.
* module/ice-9/psyntax.scm (syntax-type): Handle a new type, module-ref.
Like external-macro, it also has a procedure as a binding.
(chi-expr): module-ref forms -- that is to say, (@ (foo ...) bar) -- as
expressions they are global references, but with respect to a specific
module.
(@, @@): Define module-ref syntax handlers.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/syncase.scm: Mark as primitive syntax so we don't clobber
their definitions.
The reason I'm doing things like this is so as to support (set! (@@ ...)
...) sensibly, which will be the next patch.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (syntax-type): Look up the type of the car of
a form relative to its module, if it is a syntax object. Fixes hygiene
wrt modules and private macros.
* module/ice-9/syncase.scm (sc-macro): Add a comment.
* module/system/base/pmatch.scm: The big test case: just export pmatch,
not ppat too.
* module/ice-9/expand-support.scm (strip-expansion-structures): Enable
@/@@ substitution.
* module/ice-9/psyntax-pp.scm: Recompile.
* module/ice-9/psyntax.scm: Since syntax objects are quotable, make the
module field the module name, not the module itself. Scope the operand
of global calls appropriately. Thread modules through syntax-dispatch
destructuring. Houston, we have hygiene.
* module/ice-9/syncase.scm: Adapt to module / module-name changes.
* module/ice-9/compile-psyntax.scm: No more expansion-eval-closure.
* module/ice-9/expand-support.scm (strip-expansion-structures): Only @@
names whose module is not the current module. Actually @@ serialization
is disabled for this commit, just to get this one in and keep things
working.
* module/ice-9/psyntax-pp.scm: Recompiled.
* module/ice-9/psyntax.scm (put-global-definition-hook)
(get-global-definition-hook): Instead of going through that stupid
getprop/putprop interface, let's just inline Guile-specific code here.
(build-global-reference, build-global-assignment): Fix a bug where the
module and public? were switched, which happily allowed things to
compile. (We reintroduce a similar bug above in expand-support.)
(lookup): Add a module argument.
(global-extend): Adapt for put-global-definition-hook invocation.
(syntax-type): Lookup with mod. Return mod even for lexicals and
define-form -- why not.
(chi-top, fluid-let-syntax, syntax, set!): Lookup with mod. Wrap with
mod.
* module/ice-9/syncase.scm (expansion-eval-closure)
(current-eval-closure, env->eval-closure): OK! So the idea is: module
hygiene is syncase's business, not ours. So lose the eval-closure
fluid. Also, eval closures are so 1990s.
(sc-macro): But, we have to take the module from the env, sadly. In the
future this will be different.
Remove the rest of the eval-closure bits. Enable source reporting,
while we're debugging.
* module/language/scheme/compile-ghil.scm (lookup-transformer): Adapt for
eval closure fluid changes.
* libguile/debug.h:
* libguile/debug.c (scm_procedure_module): New procedure, returns the
module that was current when the given procedure was defined. Used by
syncase to scope free identifiers.
* module/ice-9/psyntax-pp.scm: Recompiled.
* module/ice-9/psyntax.scm: Thread the module through the syntax
expansion. This is harder than it would appear because in many places
the different components of syntax objects are destructured.
* module/ice-9/syncase.scm (guile-macro): Adapt to new signature for
syntax transformer functions.
* module/ice-9/Makefile.am: Replace annotate.scm with expand-support.scm.
* module/ice-9/annotate.scm: Removed; subsumed into expand-support.scm.
* module/ice-9/compile-psyntax.scm: Strip out expansion structures before
writing to disk.
* module/ice-9/expand-support.scm: New file. Provides annotation support,
and other compound data types for use by the expander. Currently the
only one that is used is the toplevel reference, <module-ref>, but we
will record lexicals this way soon.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (build-global-reference)
(build-global-assignment): Instead of expanding out global references
as symbols, expand them as <module-ref> structures, with space to
record the module that they should be scoped against. This is in
anticipation of us actually threading the module info through the
syntax transformation, so that we can get hygiene with respect to
modules.
* module/ice-9/syncase.scm: Replace eval-when. Since sc-expand will give
us something that isn't Scheme because we put the <module-ref>
structures in it, strip that info whenever we actually do need scheme.
* module/language/scheme/compile-ghil.scm (lookup-transformer): Strip
expansion structures here too.
* module/language/scheme/expand.scm (language): Swap annotate for
expand-support. But this file will die soon, I think.
* module/ice-9/annotate.scm (deannotate/source-properties): Version of
deannotate that sets source properties on the resulting expressions.
* module/ice-9/syncase.scm (sc-macro, syncase): Annotate expressions
before they go into syncase, and deannotate/source-properties when they
come out. The upshot is that syncase now understands source
information, yay!
* module/ice-9/annotate.scm (<annotation>): Slightly more concise
printing.
(annotate): Don't create annotations if we have no source info.
* module/ice-9/psyntax.scm (annotation?): Remove this definition, as we
now provide annotation support.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/syncase.scm: Use (ice-9 annotate).
* module/language/scheme/expand.scm (eval-when): Define the eval-when
transformer.
Moved ice-9/ and oop/ under module/, with the idea being that we have
only scheme under module/. Adjusted configure.in and Makefile.am
appropriately. Put oop/ at the end of the compilation order.