Subject: [clisp-list] Bug in macro-lambda-list &key processing?

From: Frode Vatvedt Fjeld <[email-masked]>
Date: Fri Jan 16 10:51:02 2004

It seems to me there is a bug in the processing of &key arguments with
explicit keyword-names for macros:

[45]> (defmacro foo (&key ((key var))) `(list ',var))
FOO
[46]> (foo key 42)

*** - EVAL: variable KEY has no value
The following restarts are available:
STORE-VALUE    :R1      You may input a new value for KEY.
USE-VALUE      :R2      You may input a value to be used instead of KEY.

Break 1 [47]> 
[48]> (foo)       

*** - EVAL: variable KEY has no value
The following restarts are available:
STORE-VALUE    :R1      You may input a new value for KEY.
USE-VALUE      :R2      You may input a value to be used instead of KEY.

Break 1 [49]> 
[50]> (lisp-implementation-version)  
"2.32 (2003-12-29) (built 3283257766) (memory 3283257953)"
[51]> 

Apparently, CLisp tries to evaluate the keyword-name during
macroexpansion. This happens to work for symbols in the keyword
package, but otherwise not.

-- 
Frode Vatvedt Fjeld

---

From: Sam Steingold <[email-masked]>
Date: Fri Jan 16 11:20:01 2004

> * Frode Vatvedt Fjeld <[email-masked]> [2004-01-16 19:09:20 +0100]:
>

thanks for your bug report.
please try the appended patch.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Man has 2 states: hungry/angry and sate/sleepy.  Catch him in transition.

--- defmacro.lisp.~1.24.~	2003-12-05 13:30:51.715826900 -0500
+++ defmacro.lisp	2004-01-16 14:05:57.106417200 -0500
@@ -129,7 +129,7 @@
 (defun kwd-arg-form (restvar kw svar default &aux (dummy '#.(cons nil nil)))
   ;; the default value should not be evaluated unless it is actually used
   (let ((arg (gensym "KWD-ARG-")))
-    `(let ((,arg (GETF ,restvar ,kw ',dummy)))
+    `(let ((,arg (GETF ,restvar ',kw ',dummy)))
        (if (eq ,arg ',dummy)
            (progn ,@(when svar `((setq ,svar nil))) ,default)
            ,arg))))
@@ -163,7 +163,7 @@
            (cond ((symbolp next)  ; foo
                   (setq kw (intern (symbol-name next) *keyword-package*))
                   (setq %let-list
-                        (cons `(,next (GETF ,restvar ,kw NIL)) %let-list))
+                        (cons `(,next (GETF ,restvar ',kw NIL)) %let-list))
                   (setq kwlist (cons kw kwlist)))
                  ((atom next)
                   (cerror (TEXT "It will be ignored.")