From 87dd91e6ae779ae293c78bd0e61173683a72c416 Mon Sep 17 00:00:00 2001 From: Daniel Gackle Date: Mon, 21 Sep 2009 18:20:50 -0600 Subject: [PATCH] Fixed a bug in PS LOOP: the :INITIALLY and :FINALLY clauses should execute whether or not the loop body is executed. --- src/lib/ps-loop.lisp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/lib/ps-loop.lisp b/src/lib/ps-loop.lisp index cfdbcd0..fbd6b39 100644 --- a/src/lib/ps-loop.lisp +++ b/src/lib/ps-loop.lisp @@ -250,16 +250,14 @@ ,@(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 @@ -269,7 +267,7 @@ (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 -- 2.20.1