Re: robust unhygienic macros
Chris Hanson 27 Aug 2022 21:49 UTC
Nit: the code from Note 2:
(define-syntax foo
(er-macro-transformer
(lambda (x r c)
`(,(r loop) (exit ,(cadr x))))))
Has a typo: ,(r loop) should be ,(r 'loop)
On Sunday, August 21, 2022 11:16:50 PM PDT Marc Nieper-Wißkirchen wrote:
> Am Mo., 22. Aug. 2022 um 00:29 Uhr schrieb Chris Hanson <xxxxxx@chris-
hanson.org>:
> > I’m not familiar with the term "robust unhygienic macros” and an internet
> > search didn’t reveal any definitions.
>
> The term was coined by myself for the purpose of SRFI 211.
>
> > Is there a definition of this term, or better yet, a paper?
>
> Unfortunately no.
>
> What I mean by a "robust unhygienic macro" is an unhygienic macro that
> even works when the unhygienic macro becomes part of the body of a
> second macro expansion.
>
> Please see "Note 2" under "Explicit-renaming macro" for an example.
>
> > I’m a little confused because the SRFI claims that explicit-renaming
> > macros
> > can produce "robust unhygienic macros” yet syntactic-closure macros
> > cannot.
> > However, explicit-renaming is virtually identical to “reverse” syntactic-
> > closure macros, which are syntactic-closure macros with the definition and
> > use environments flipped.
>
> ER macros implemented with SC (syntactic closures) are indeed not
> "robust" (according to my findings). SRFI 211 describes a variation of
> ER (implemented with marks & substitutions) that can be used to define
> unhygienic macros that are "robust". The variation of ER is not 100%
> compatible with how ER is classically implemented.
>
> You can write down the example in Note 2 for SC as well.
>
> Does this help?
>
> Thanks,
>
> Marc
>
> PS My time this week is limited, so please excuse the rather brief reply.