Subject: [clisp-list] Recursive macros

From: Bruce <[email-masked]>
Date: Thu, 05 Jul 2001 10:22:31 +0800

While reading Dr. Graham's book, "On Lisp", I found it difficult to 
appreciate the difference between two recursive macros that he said one 
is bad and the other is good.

Bad one (P.140):
(defmacro nthb (n lst)
   `(if (= ,n 0)
        (car ,lst)
      (nthb (- ,n 1) (cdr ,lst))))

Good one (P.142):
(defmacro orb (&rest args)
   (if (null args)
       nil
     (let ((sym (gensym)))
       `(let ((,sym ,(car args)))
          (if ,sym
              ,sym
            (orb ,@(cdr args)))))))

It is clear to see that both macros are recursive. Dr. Graham said in 
the book that the good one is good because it recurses on the arguments 
to the macro, not on the values of the arguments. That seems to make sense.

But when I tested on CLISP and CMUCL, I found that CLISP happily accepts 
both macros but CMUCL runs in endless loop with the bad one.

My question is: Is CLISP doing the right thing or CLISP implementation 
more conformant to the new ISO standard (Dr. Graham's statement no 
longer holds)?

Best!