Re: robust unhygienic macros
Ray Dillinger 22 Aug 2022 00:59 UTC
On 8/21/22 15:29, Chris Hanson wrote:
> I’m not familiar with the term "robust unhygienic macros” and an internet
> search didn’t reveal any definitions.
There are a couple of ways to achieve Scheme's normal macro semantics.
The one we usually think of is renaming; all variables are renamed to
avoid scope conflicts. The other formulation, which achieves
approximately the same thing, is to convert arguments to
'name+environment reference' promises and ensure that all evaluations of
named arguments are handled as evaluations of the name (from the
promise) in its own environment (to which the promise refers). The
macro therefore has no access to anything in the lexical environment at
the call site except what was explicitly passed to it. All other
expressions are evaluated in the lexical environment visible at the
macro definition site.
"Robust unhygienic macros" IIRC is an extension to the second
formulation that adds a rule allowing *assignments* to those promises,
before, after, or instead of evaluating them. The extension uses the
promises to make assignments to the original variables in their own
lexical scopes.
If I recall correctly, this was developed by John Shutt as part of the
work that led up to his formulation of the vau-calculus (and his
vau-calculus lisp, which he named Kernel.)
Bear