[plt-scheme] Breaking hygiene
At Wed, 13 Apr 2005 07:57:50 -0400, Sam Tobin-Hochstadt wrote:
> On Wed, 2005-04-13 at 12:17 +0100, Matt Jadud wrote:
> > #`(define #,(syntax-object->datum generated-foo)
> > #,wrapped-body)
> >
> > where 'generated-foo' might expand to an identifier 'foo'. However, any
> > references to 'foo' in the body will *not* be the same 'foo', as they
> > exist at two different times in the expansion tower. Furthermore, if I
> > were to make the introduced identifier the same as the identifier found
> > in the 'wrapped-body', then I would be breaking hygiene.
> >
> > Is this correct? That is, I am trying to break hygiene, yes?
>
> If you want to expand to something like this:
>
> (define (foo) body)
>
> where any occurences foo in body are bound by the define, and foo is an
> identifier you chose, not an input to the macro, then yes, you are
> trying to break hygiene.
I think there must be a bit more to the story, because the macro can't
invent an arbitrary `foo' be invented if it's already being used in
`body'.
If `foo' is a constant name (like `break' in a loop), then I recommend
using "stxparam.ss" from MzLib instead of breaking hygiene. If `foo' is
based on a different identifier that is supplied to the macro, then
usually it's enough to use the context the the base identifier. Or
maybe it's something else.
Matt, can you tell us more concretely what your macro is supposed to
do?
Matthew