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

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

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

> Ryan Culpepper wrote:
> >>But - suppose I can't change the library in question, what then?
> > 
> > In that case, the least painful solution is to call your struct
> > something else. Your idea of making an identifier macro will not
> > work, because comparing identifiers doesn't involve expanding
> them,
> > so your macro would never get called.
> 
> Not even if an intermediary module my-42.ss that imports
> and rexports bindings from 42.ss was introduced?

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.

Ryan



Posted on the users mailing list.