<p>Reynolds is referring to so-called <em>unhygenic</em> macros, as found in traditional Lisp implementations, including modern Common Lisp.  The basic problem is that a variable referenced in a macro might change behavior when the macro is used, or that a variable seemingly bound around a macro use could be inadvertently captured by the macro.</p>

<p>These issues were first remedied in macro systems for Scheme, in particular Kohlbecker et al's 1986 paper <a href="http://dl.acm.org/citation.cfm?id=319838.319859"><em>Hygenic Macro Expansion</em></a>, and improved by Clinger and Rees' 1991 paper <a href="http://dl.acm.org/citation.cfm?id=99583.99607"><em>Macros that Work</em></a>.</p>

CC BY-SA 3.0
2012-01-29T20:57:59.257Z
2012-01-29T20:57:59.257Z
Sam Tobin-Hochstadt
<p>See chapter 1 of Robert Harper's book <a href="http://www.cs.cmu.edu/~rwh/plbook/book.pdf"><em>Practical Foundations of Programming Languages</em></a>. He formalizes syntax with binding operators using the notion of "abstract binding trees", which IIRC were originally introduced in the Nuprl proof assistant. The main keyword you need to find further information is "alpha-equivalence". </p>

CC BY-SA 3.0
2012-01-28T20:28:35.470Z
2012-01-28T20:28:35.470Z
Neel Krishnaswami
<p>I recently came across this passage in an <a href="http://repository.cmu.edu/compsci/1286/" rel="nofollow">article by John Reynolds</a> (emphasis added):</p>

<blockquote>
  <p>...from designers innocent of the principles of programming language design, we have been given a nearly endless succession of “input formats” that seem to be designed to encourage error. (Flawed macro facilities that violate <em>the basic laws of variable binding</em> are particularly prominent examples.)</p>
</blockquote>

<p>I was happy to come across the phrase in italics because for some time now I've been aware of having precisely this deficiency, but not knowing what to call it, and therefore failing repeatedly at finding a way to remedy it.</p>

<p>Can someone point me to where I can learn about these "basic laws of variable binding"?</p>

CC BY-SA 3.0
2012-02-20T18:59:03.030Z
For implementation you could use http://en.wikipedia.org/wiki/De_Bruijn_index
Radu GRIGore
<pl.programming-languages><language-design>
Reynolds: "the basic laws of variable binding"
kjo
# Reynolds: "the basic laws of variable binding"

(Asked by: username_0 on 2012-01-28)

I recently came across this passage in an [article by John Reynolds](http://repository.cmu.edu/compsci/1286/) (emphasis added):

> ...from designers innocent of the principles of programming language design, we have been given a nearly endless succession of “input formats” that seem to be designed to encourage error. (Flawed macro facilities that violate *the basic laws of variable binding* are particularly prominent examples.)

I was happy to come across the phrase in italics because for some time now I've been aware of having precisely this deficiency, but not knowing what to call it, and therefore failing repeatedly at finding a way to remedy it.

Can someone point me to where I can learn about these "basic laws of variable binding"?

**Tags:** pl.programming-languages, language-design

> **Comments:**
> **username_1**: For implementation you could use http://en.wikipedia.org/wiki/De_Bruijn_index  

---

## 2 answers

### Answer by username_3 on 2012-01-28. Score: 8 | Accepted answer

See chapter 1 of Robert Harper's book [*Practical Foundations of Programming Languages*](http://www.cs.cmu.edu/~rwh/plbook/book.pdf). He formalizes syntax with binding operators using the notion of "abstract binding trees", which IIRC were originally introduced in the Nuprl proof assistant. The main keyword you need to find further information is "alpha-equivalence".


---

### Answer by username_2 on 2012-01-29. Score: 6

Reynolds is referring to so-called *unhygenic* macros, as found in traditional Lisp implementations, including modern Common Lisp. The basic problem is that a variable referenced in a macro might change behavior when the macro is used, or that a variable seemingly bound around a macro use could be inadvertently captured by the macro.

These issues were first remedied in macro systems for Scheme, in particular Kohlbecker et al's 1986 paper [*Hygenic Macro Expansion*](http://dl.acm.org/citation.cfm?id=319838.319859), and improved by Clinger and Rees' 1991 paper [*Macros that Work*](http://dl.acm.org/citation.cfm?id=99583.99607).


---

