Fixed a bug in PS LOOP: the :INITIALLY and :FINALLY clauses should execute whether...
authorDaniel Gackle <danielgackle@gmail.com>
Tue, 22 Sep 2009 00:20:50 +0000 (18:20 -0600)
committerDaniel Gackle <danielgackle@gmail.com>
Tue, 22 Sep 2009 00:20:50 +0000 (18:20 -0600)
src/lib/ps-loop.lisp

index cfdbcd0..fbd6b39 100644 (file)
      ,@(finally loop)))
 
 (defun loop-form-with-alternating-tests (loop)
-  (let ((form (wrap-with-initially-and-finally
-               loop
-               `(while t
-                  ,@(wrap-with-first-and-last-guards
-                     loop
-                     (append (body loop)
-                             (loop :for (var bindings nil step test) :in (iterations loop)
-                               :collect `(setf ,var ,step)
-                               :collect `(dset ,bindings ,var)
-                               :when test :collect `(when ,test (break)))))))))
+  (let ((form `(while t
+                 ,@(wrap-with-first-and-last-guards
+                    loop
+                    (append (body loop)
+                            (loop :for (var bindings nil step test) :in (iterations loop)
+                              :collect `(setf ,var ,step)
+                              :collect `(dset ,bindings ,var)
+                              :when test :collect `(when ,test (break))))))))
     ;; preface the whole thing with alternating inits and tests prior
     ;; to first executing the loop; this way, like CL LOOP, we refrain
     ;; from initializing subsequent clauses if a test fails
       (when bindings
         (setf form `(destructuring-bind ,bindings ,var ,form)))
       (setf form `(let ((,var ,init)) ,form)))
-    form))
+    (wrap-with-initially-and-finally loop form)))
 
 (defun simple-for-form (loop)
   (wrap-with-initially-and-finally