Macro prohibits recursive calls among locally defined macros?

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?

+4
source share
1

, macrolet, , macrolet. , macrolet, , macrolet. :

(macrolet ((jump (x) `(car ,x))
           ;; Okay since skip expands into jump.
           (skip (x) `(jump ,x)))
  (skip '(1 2 3))) 

=> 1

(macrolet ((jump (x) `(car ,x))
           ;; Wrong since skip uses jump directly.
           (skip (x) (jump x)))
  (skip '(1 2 3))) 

=> Error: The function COMMON-LISP-USER::JUMP is undefined.
+7

All Articles