I'm a complete beginner to LISP, and have been following Practical Common LISP to learn it, using the recommended LISPBox with Allegro. There weren't any issues until I get to the part in Chapter 9 where the macro (combine-results) is written. My question relates specifically to the use of getsyms. This is the code I end up with following the book:
Code: Select all
(defun test-+ ()
(check
(= (+ 1 2) 3)
(= (+ 1 2 3) 6)
(= (+ -1 -3) -4)))
(defun report-result (result form)
(format t "~:[FAIL~;pass~] ... ~a~%" result form)
result)
(defmacro check (&body forms)
`(combine-results
,@(loop for f in forms collect `(report-result ,f ',f))))
(defmacro combine-results (&body forms)
(with-gensyms (result)
`(let ((,result t))
,@(loop for f in forms collect `(unless ,f (setf ,result nil)))
,result)))
Code: Select all
Warning: While compiling these undefined functions were referenced:
WITH-GENSYMS from position 265 in test.lisp;298
RESULT from position 265 in test.lisp;298
Code: Select all
(let ((variable (gensym)))
...)
Code: Select all
(defmacro combine-results (&body forms)
(let ((result (gensym)))
`(let ((,result t))
,@(loop for f in forms collect `(unless ,f (setf ,result nil)))
,result)))
So, I suppose my question now is to do with (with-gensyms). Is it actually a function in LISP? And, if so, what is wrong with my use of it?
Thank you in advance.