title: A problem with my macro for partial application in Common Lisp
body: <p>I am trying to make a macro to achieve partial application in Common Lisp. Here was my thought on how I would implement that in pseudocode:</p>
  <pre><code>If my argument list is null, return the function body
  Otherwise, cons together &quot;lambda&quot; with the first argument with a recursive call to &quot;partial-lambda&quot; again
  
  (lambda (x y z) (+ x y z) =&gt; (lambda (x) (lambda (y) (lambda (z) (+ x y z))))
  </code></pre>
  <p>Here's my code:</p>
  <pre class="lang-lisp prettyprint-override"><code>(defmacro partial-lambda (params &amp;rest body)
      (if (null params) body
          (lambda ((car params)) (partial-lambda (cdr params) body))))
  
  (partial-lambda (x y z) (+ x y z))
  </code></pre>
  <p>Unfortunately, SBCL gives me this error:</p>
  <pre><code>; in: DEFMACRO PARTIAL-LAMBDA
  ;     (LAMBDA (CAR PARAMS) (PARTIAL-LAMBDA (CDR PARAMS) BODY))
  ; ==&gt;
  ;   #'(LAMBDA (CAR PARAMS) (PARTIAL-LAMBDA (CDR PARAMS) BODY))
  ; 
  ; caught STYLE-WARNING:
  ;   The variable CAR is defined but never used.
  
  ; file: /Users/caspianahlberg/Desktop/Programming/Lisp/partial_application.lisp
  ; in: DEFMACRO PARTIAL-LAMBDA
  ;     (PARTIAL-LAMBDA (CDR PARAMS) BODY)
  ; 
  ; caught STYLE-WARNING:
  ;   undefined function: COMMON-LISP-USER::PARTIAL-LAMBDA
  ; 
  ; compilation unit finished
  ;   Undefined function:
  ;     PARTIAL-LAMBDA
  ;   caught 2 STYLE-WARNING conditions
  STYLE-WARNING:
     PARTIAL-LAMBDA is being redefined as a macro when it was previously assumed to be a function.
  </code></pre>
  <p>Why does it complain about <code>car</code> never being used? I find that really confusing. Does anyone who is good with CL macros know what I am doing wrong?</p>