[plt-scheme] Breaking hygiene

From: Matt Jadud (mcj4 at kent.ac.uk)
Date: Wed Apr 13 07:17:11 EDT 2005

I think I've tracked down the problem in a macro I've written, and I 
think it's because I'm trying to break hygiene. I seem to try and do 
this a lot.

If I write (in Scheme)

(define foo
  (lambda (...) ... (foo ...)))

(where the ... are your conversational, "I-don't-want-to-fill-this-in" 
...s, not syntax pattern ...s)

'foo' is bound to the top-level definition. However, if I write a macro 
that spits out syntax like

#`(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?

Thanks,
Matt

PS. Perhaps another thread, but how do people develop and debug 
significant macros? Or, do they just "get it right" the first time around?



Posted on the users mailing list.