[plt-scheme] Macro problem: struct name coincides with macro keyword

From: Ryan Culpepper (ryan_sml at yahoo.com)
Date: Wed May 3 18:54:21 EDT 2006

--- Jens Axel Søgaard <jensaxel at soegaard.net> wrote:

> Ryan Culpepper wrote:
> > If it's just re-exporting the same bindings, I don't see how that
> > would help. If it adds a binding for index, then that's no better
> > than  having a definition of index in the module where you use
> > list-ec---the : generator will only accept an index identifier
> that
> > means "nothing in particular". If you write down index where some
> > definition is in scope, either your struct or some other binding,
> the
> > macro pattern will fail to match.
> > 
> > I can think of three solutions. The first is to change the SRFI
> code.
> > The second is to name your struct something else. The third is to
> > create another module where index is not bound and write an
> "insert
> > the identifier 'index' here" macro. That macro must produce the
> > entire list-ec expression, or maybe just the generator
> expression;
> > I'm not sure. But you'd have to use it in an expansion context,
> not
> > as a macro that just produced the one identifier.
> Okay. I'll change the srfi code for my program.
> Hmm. Consider this situation:
>     Module A uses library B and library C.
>     Library B uses the keyword index just as the SRFI 42 code.
>     Library C on the other hand uses the define-index-as-
>     out-of-context-macro.
>     Can module A use macros using the index keyword from
>     library B?

Yes, but it would have to require-rename the index macro from C to
something else.


Posted on the users mailing list.