title: Lisp evaluation aborted on unbound variable
body: <p>During the first example (the database example) in <a href="http://www.gigamonkeys.com/book/" rel="nofollow">Practical Common Lisp</a>, the author uses a macro and a couple support functions in order to replace a larger function, named <code>where</code>. The code works fine when <code>where</code> is a function, but the macro setup returns "undefined variable" and "unbound variable" errors. (Note that I commented out the original function, restarted Emacs and recompiled my file once adding the <code>where</code> macro.) </p>
  
  <p>The caught style-warning in the REPL is most suspect to me since the macro should evaluate with <code>ROW</code> rather than <code>CD</code>, according to the example. Why is <code>ROW</code> unused? How do I resolve this warning?</p>
  
  <p>This is printed in the REPL:</p>
  
  <pre><code>; in: SELECT (WHERE :TITLE "Animals" :RIPPED T)
  ;     (WHERE :TITLE "Animals" :RIPPED T)
  ; ==&gt;
  ;   #'(LAMBDA (ROW)
  ;       (AND (EQUAL (GETF CD :TITLE) "Animals") (EQUAL (GETF CD :RIPPED) T)))
  ; 
  ; caught STYLE-WARNING:
  ;   The variable ROW is defined but never used.
  
  ; in: SELECT (WHERE :TITLE "Animals" :RIPPED T)
  ;     (WHERE :TITLE "Animals" :RIPPED T)
  ; --&gt; FUNCTION AND IF EQUAL 
  ; ==&gt;
  ;   (GETF CD :TITLE)
  ; 
  ; caught WARNING:
  ;   undefined variable: CD
  ; 
  ; compilation unit finished
  ;   Undefined variable:
  ;     CD
  ;   caught 1 WARNING condition
  ;   caught 1 STYLE-WARNING condition
  </code></pre>
  
  <p>This is printed in the debug space:</p>
  
  <pre><code>The variable CD is unbound.
     [Condition of type UNBOUND-VARIABLE]
  </code></pre>
  
  <p>Here are the support functions and macro in my .lisp file:</p>
  
  <pre><code>; this function is used in both implementations. *db* is a (global) database
  (defun select (selector-fn)
    (remove-if-not selector-fn *db*))
  
  (defun make-comparison-expr (field value)
    `(equal (getf cd ,field) ,value))
  
  (defun make-comparisons-list (fields)
    (loop while fields
         collecting (make-comparison-expr (pop fields) (pop fields))))
  
  (defmacro where (&amp;rest clauses)
    `#'(lambda (row) (and ,@(make-comparisons-list clauses))))
  </code></pre>
  
  <p>I'm using SBCL, Emacs and Slime.</p>