0.7.9.61:
authorChristophe Rhodes <csr21@cam.ac.uk>
Thu, 21 Nov 2002 15:55:43 +0000 (15:55 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Thu, 21 Nov 2002 15:55:43 +0000 (15:55 +0000)
Fix destructuring of LOOP WITH <x> where <x> is a tree with NIL
in it.
... define and use a somewhat KLUDGEy LOOP-DESTRUCTURING-BIND.

NEWS
src/code/loop.lisp
tests/loop.pure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index e0f8543..0f57910 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1402,8 +1402,10 @@ changes in sbcl-0.7.10 relative to sbcl-0.7.9:
     ** NCONC accepts any object as its last argument;
     ** :COUNT argument to sequence functions may be BIGNUM; (thanks to
        Gerd Moellman)
-    ** Loop-package does not require a package to be explicitely
+    ** loop-for-as-package does not require a package to be explicitely
        specified;
+    ** LOOP WITH now treats NIL in the d-var-spec correctly as an
+       ignored binding;
   * fixed bug 166: compiler preserves "there is a way to go"
     invariant when deleting code.
   * fixed bug 172: macro lambda lists with required arguments after
index d03284b..a1cec36 100644 (file)
@@ -760,9 +760,27 @@ code to be loaded.
                           specified-type required-type)))
        specified-type)))
 \f
+(defun subst-gensyms-for-nil (tree)
+  (declare (special *ignores*))
+  (cond
+    ((null tree) (car (push (gensym "LOOP-IGNORED-VAR-") *ignores*)))
+    ((atom tree) tree)
+    (t (cons (subst-gensyms-for-nil (car tree))
+            (subst-gensyms-for-nil (cdr tree))))))
+    
+(sb!int:defmacro-mundanely loop-destructuring-bind
+    (lambda-list arg-list &rest body)
+  (let ((*ignores* nil))
+    (declare (special *ignores*))
+    (let ((d-var-lambda-list (subst-gensyms-for-nil lambda-list)))
+      `(destructuring-bind ,d-var-lambda-list
+          ,arg-list
+        (declare (ignore ,@*ignores*))
+         ,@body))))
+
 (defun loop-build-destructuring-bindings (crocks forms)
   (if crocks
-      `((destructuring-bind ,(car crocks) ,(cadr crocks)
+      `((loop-destructuring-bind ,(car crocks) ,(cadr crocks)
         ,@(loop-build-destructuring-bindings (cddr crocks) forms)))
       forms))
 
index 307129b..067f7ef 100644 (file)
              (loop named foo do (loop-finish) finally (return :good))
              :bad)
            :good))
+
+(assert (= (loop with (a nil) = '(1 2) return a) 1))
+(assert (= (loop with (nil a) = '(1 2) return a) 2))
+(assert (= (loop with (a . nil) = '(1 2) return a) 1))
+(assert (equal (loop with (nil . a) = '(1 2) return a) '(2)))
index a851108..8f69244 100644 (file)
@@ -18,4 +18,4 @@
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.7.9.60"
+"0.7.9.61"