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: "Marisha Ray & Neil Jerram" <mpriz at dircon dot co dot uk>
- Date: Tue, 28 Dec 1999 11:18:34 -0000
- Cc: <guile at sourceware dot cygnus dot com>
From: Rob Browning <rlb@cs.utexas.edu>
>
>I'm a little confused about define-syntax and syntax-rules as
>implemented by syntax-rules. If I say
>
> ;; file a
> (define-module (x a))
> (defmacro baz () 21)
> (export-syntax baz)
>
> ;; file b
> (define-module (x b))
> (define-syntax foobar
> (syntax-rules ()
> ((foobar) (baz)))
> (export-syntax foobar)
>
>and then from the guile top-level I say (use-modules (x b)) and try to
>evaluate (foobar), I get an error because baz is not defined at the
>top level. This seems to indicate that foobar isn't recursively
>expanding baz at macroexpansion time. Why not?
(Well I'm still testing my own understanding here, but I think ...)
Because baz in file b is an unbound variable. There's no way for the macro
expander to know that baz may later be bound to syntax and so should be
expanded (whatever that could mean).
I guess it would work if you changed the first line of file b to
(define-module (x b) :use-module (x a)).
A third possibility: I'm not sure what happens if you say (use-modules (x
a)) at top level before (use-modules (x b)). The export-syntax in file a
will then export baz into the guile top-level environment, but is the guile
top-level environment inherited when loading (x b)?
Neil