I am doing Exercise 14.11 in “A Gentle Introduction to Symbolic Computation,” and wrote the following function:
(defmacro compile-machine (nodes)
`(progn ,@(mapcar #'compile-node nodes)))
When calling (compile-machine *nodes*), where *nodes* is a list of NODE structures, I get the following error:
Error: *NODES* is not of type LIST.
So I see what *nodes* is, and
CL-USER 116 > *nodes*
(#<Node START> #<Node HAVE-5> #<Node HAVE-10> #<Node HAVE-15> #<Node HAVE-20> #<Node HAVE-25> #<Node END>)
CL-USER 117 > (type-of *nodes*)
CONS
CL-USER 118 > (listp *nodes*)
T
It seems as if *nodes* is indeed a list. What am I doing wrong here?
EDIT: More code that can perhaps clarify
(defun compile-arc (arc)
`((equal this-input ',(arc-label arc))
(format t "~&~A" ,(arc-action arc))
(,(node-name (arc-to arc)) (rest input-syms))))
(defun compile-node (node)
`(defun ,(node-name node) (input-syms &aux (this-input (first input-syms)))
(cond ((null input-syms) ',(node-name node))
,@(mapcar #'compile-arc (node-outputs node)) ;isn't this basically the same?
(t (error "No arc from ~A with label ~A." ;and yet Lisp doesn't complain
',(node-name node) this-input)))))
The value of
*NODES*is a list, but itself it is a symbol.