In his book ANSI Common Lisp , p. 320, Paul Graham writes macrolet: "How flet, local macros cannot call each other."
I may have misunderstood this, but I cannot figure out how this might be true. Macros do not call each other as much as they expand in each other, and the nature of macro expansion is such that it continues until all the macros defined in the region are expanded.
Code such as the following is not consistent with Graham in every implementation of Common Lisp I tried:
(macrolet ((jump (x) `(car ,x))
(skip (x) `(jump ,x))
(hop (x) `(skip ,x)))
(hop '(1 2 3)))
=> 1
(macrolet ((yin (n x)
(if (zerop n)
`(cdr ,x)
`(yang ,(1- n) ,x)))
(yang (n x)
(if (zerop n)
`(car ,x)
`(yin ,(1- n) ,x))))
(yin 6 '(1 2 3)))
=> (2 3)
Is Graham's expression a mistake?
source
share