I am new to Lisp and I am reading through Doug Hoyte's Let Over Lambda and he presents Paul Graham's nif macro in Chapter 3. I was playing around with that and made these two macros:
(defmacro niffy (expr pos zero neg)
`(cond ((plusp ,expr) ,pos)
((zerop ,expr) ,zero)
(t ,neg)))
(defmacro niffy2 (expr pos zero neg)
`(let ((x ,expr))
(cond ((plusp x) ,pos)
((zerop x) ,zero
(t ,neg)))))
When I do (macroexpand '(niffy2 10 "positive" "zero" "negative")), I get what I expect: (LET ((X 10)) (COND ((PLUSP X) "positive") ((ZEROP X) "zero" (T "negative"))))
But when I do (macroexpand '(niffy 10 "positive" "zero" "negative")) I just get the evaluated form "positive". Which confuses me because in niffy, cond is backquoted, so I thought that meant it wouldn't be evaluated. Evaluating both niffy and niffy2 without the macro expansion both work exactly as I expect, returning "positive", "zero", and "negative" for positive, zero, and negative values respectively.