This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Quick syncase/syntax-rules question.
- To: Rob Browning <rlb at cs dot utexas dot edu>
- Subject: Re: Quick syncase/syntax-rules question.
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 04 Jan 2000 19:14:36 +0100
- Cc: guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <87u2l31w74.fsf@raven.localnet> <87iu1i2ocm.fsf@raven.localnet>
Rob Browning <rlb@cs.utexas.edu> writes:
> So after some more experimentation, it looks like define-syntax
> doesn't do recursive expansions on the template replacements at all.
> Is that "correct"? If so, it seems to substantially limit the
> usefulness of define-syntax/syntax-case.
>
> (foobar) from the top level will fail with a module defined like this:
>
> (define-module (some module))
> (use-modules (ice-9 syncase))
>
> (defmacro baz () 42)
>
> (define-syntax foobar
> (syntax-rules ()
> ((foobar) (baz))))
>
> (export-syntax foobar)
[I assume that you have done (use-modules (some module)) at toplevel.]
(foobar) fails because it expands to (baz) which doesn't have a
binding at toplevel. If you export baz from (some module), it will
work.
This is of course a serious bug in the macro/module system: The baz
binding should not be looked up in the toplevel module but in the
lexical scope of foobar = (some module).
It will be possible to address this problem once Jost Boekemeier's
environment patches has been applied.