[plt-scheme] Macros in the same module

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Thu May 7 15:08:32 EDT 2009

On Thu, May 7, 2009 at 1:25 PM, Noel Welsh <noelwelsh at gmail.com> wrote:
> I think you want a define-for-syntax not a define-syntax, or you need
> to put 'expand-rules' into a (syntax ...). One macro can definitely
> expand into another:
>
> #lang scheme/base
>
> (define-syntax foo
>  (syntax-rules ()
>    [(foo name val)
>     (bar name val)]))
>
> (define-syntax bar
>  (syntax-rules ()
>    [(bar name val)
>     (define name val)]))
>
> (foo a 42)
> a
>

Hi Noel,

Thanks, I knew that I could do that, but I am using syntax-case which
I am not so familiar with given syntax-rules as been enough for me
each time I need to define something more complex as a macro.

Anyway, indeed, define-for-syntax works, but interestingly enough it
doesn't show up anything when I search for it in the manual.
http://docs.plt-scheme.org/search/index.html?q=define-for-syntax

any idea why?

Cheers,

Paulo Matos

> N.
>
> On Thu, May 7, 2009 at 1:00 PM, Paulo J. Matos <pocmatos at gmail.com> wrote:
>> Hi all,
>>
>> I have defined a macro which expands into a define and then uses
>> another macro defined in the same module to expand into the define
>> body.
>> However, the first macro cannot 'see' the second:
>>  expand: unbound identifier in module (in the transformer environment,
>> which does not include the macro definition that is visible to
>> run-time expressions) in: expand-rules
> ...
>



-- 
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm


Posted on the users mailing list.