Only in iterate-1.4-patched/: .backups
diff -cr global/iterate-1.4/iterate.lisp iterate-1.4-patched/iterate.lisp
*** global/iterate-1.4/iterate.lisp	2005-06-23 15:21:31.000000000 +0200
--- iterate-1.4-patched/iterate.lisp	2006-01-13 01:13:38.000000000 +0100
***************
*** 1825,1834 ****
       type)
      nil)))
  
! (defun add-binding (var value)
    (cond
     ((var-binding var)
!     (clause-error "Duplicate variable: ~a" var))
     (t
      (check-internal-variables var)
      (push (list var value) *bindings*))))
--- 1825,1836 ----
       type)
      nil)))
  
! (defun add-binding (var value &key reuse-existing)
    (cond
     ((var-binding var)
!     (if (not reuse-existing)
!         (clause-error "Duplicate variable: ~a" var)
!         nil))
     (t
      (check-internal-variables var)
      (push (list var value) *bindings*))))
***************
*** 2318,2328 ****
--- 2320,2348 ----
    (mapc #'local-binding-check forms)
    (return-code :final-protected (copy-list forms)))
  
+ ;;; Obsolete, use (if (first-time-p) ...) below
  ;;; (IF-FIRST-TIME then &optional else)
  (def-special-clause if-first-time (then &optional else)
    (return-code :body (list (if-1st-time (list (walk-expr then))
  					(list (walk-expr else))))))
  
+ ;;; (if (FIRST-TIME-P) ...) returns true for the first time it is evaluated
+ (def-special-clause FIRST-TIME-P ()
+   (let ((first-time-var (make-var-and-binding 'first-time t :type 'boolean)))
+     (return-code :body `(if ,first-time-var
+                          (progn
+                            (setf ,first-time-var nil)
+                            t)))))
+ 
+ ;;; (if (FIRST-ITERATION-P) ...) returns true in the first iteration of the loop
+ (def-special-clause FIRST-ITERATION-P ()
+   (let* ((step-body nil)
+          (first-usage (add-binding 'first-iteration t :reuse-existing t)))
+     (when first-usage
+       (setf step-body (list '(setf first-iteration nil))))
+     (return-code :body (list 'first-iteration)
+                  :step step-body)))
+ 
  ;;; (IN &body)
  (def-special-clause in (block-name &rest forms)
    "Process forms in a named Iterate block"
diff -cr global/iterate-1.4/iterate-test.lisp iterate-1.4-patched/iterate-test.lisp
*** global/iterate-1.4/iterate-test.lisp	2005-06-23 13:32:32.000000000 +0200
--- iterate-1.4-patched/iterate-test.lisp	2006-01-13 01:16:41.000000000 +0100
***************
*** 106,114 ****
  
  (deftest locally.2
      (iterate (for i in '(1 2 3)) (repeat 2)
! 	     (locally
! 	       (declare (optimize safety))
! 	       (declare (fixnum i)) (collect i)))
    (1 2))
  
  (deftest always.1
--- 106,113 ----
  
  (deftest locally.2
      (iterate (for i in '(1 2 3)) (repeat 2)
! 	     (locally (declare (fixnum i) (optimize (safety 3)))
!                (collect i)))
    (1 2))
  
  (deftest always.1
***************
*** 922,927 ****
--- 921,944 ----
  	    (collect i)))
    (1 -1 3 -1 5))
  
+ (deftest first-time-p.1
+     (iter (for i to 5)
+           (if (first-time-p) (collect -1))
+           (if (first-time-p) (collect -2))
+ 	  (when (oddp i)
+ 	    (if (first-time-p) nil (collect -1))
+ 	    (collect i)))
+   (-1 -2 1 -1 3 -1 5))
+ 
+ (deftest first-iteration-p.1
+     (iter (for i to 5)
+           (if (first-iteration-p) (collect -1))
+           (if (first-iteration-p) (collect -2))
+ 	  (when (oddp i)
+ 	    (if (first-iteration-p) nil (collect -1))
+ 	    (collect i)))
+   (-1 -2 -1 1 -1 3 -1 5))
+ 
  (deftest collect.multiple.1
      (iter (for i from 1 to 10)
  	  (collect i into nums)
***************
*** 932,938 ****
  	  collect (sqrt i)))
  
  (deftest collect.type.string.1
!     (locally (declare (optimize safety (debug 2) (speed 0) (space 1)))
        (iter (declare (iterate:declare-variables))
  	    (for s in-vector '#(\a |b| |cD|))
  	    (collect (char (symbol-name s) 0) :result-type string)))
--- 949,955 ----
  	  collect (sqrt i)))
  
  (deftest collect.type.string.1
!     (locally (declare (optimize (safety 3) (debug 2) (speed 0) (space 1)))
        (iter (declare (iterate:declare-variables))
  	    (for s in-vector '#(\a |b| |cD|))
  	    (collect (char (symbol-name s) 0) :result-type string)))
***************
*** 945,951 ****
    "aBc")
  
  (deftest collect.type.vector
!     (locally (declare (optimize safety (debug 2) (speed 0) (space 1)))
        (iter (declare (iterate:declare-variables))
  	    (for s in-vector '#(\a |b| |cD|))
  	    (collect (char (symbol-name s) 0) :result-type vector)))
--- 962,968 ----
    "aBc")
  
  (deftest collect.type.vector
!     (locally (declare (optimize (safety 3) (debug 2) (speed 0) (space 1)))
        (iter (declare (iterate:declare-variables))
  	    (for s in-vector '#(\a |b| |cD|))
  	    (collect (char (symbol-name s) 0) :result-type vector)))
***************
*** 1259,1265 ****
      (handler-case (macroexpand '
  		   (iter (for i from 1 to 10)
  			 (let ((y i))
! 			   (declare (optimize safety))
  			   (after-each (princ y)))))
        (error () t)
        (:no-error (f x) (declare (ignore f x)) nil))
--- 1276,1282 ----
      (handler-case (macroexpand '
  		   (iter (for i from 1 to 10)
  			 (let ((y i))
! 			   (declare (optimize (safety 3)))
  			   (after-each (princ y)))))
        (error () t)
        (:no-error (f x) (declare (ignore f x)) nil))
***************
*** 1271,1277 ****
  			 (let ((safety i))
  			   (after-each
  			     (let ()
! 			       (declare (optimize safety))
  			       (princ i))))))
        (error () t)
        (:no-error (f x) (declare (ignore f x)) nil))
--- 1288,1294 ----
  			 (let ((safety i))
  			   (after-each
  			     (let ()
! 			       (declare (optimize (safety 3)))
  			       (princ i))))))
        (error () t)
        (:no-error (f x) (declare (ignore f x)) nil))
diff -cr global/iterate-1.4/package.lisp iterate-1.4-patched/package.lisp
*** global/iterate-1.4/package.lisp	2005-06-23 15:19:26.000000000 +0200
--- iterate-1.4-patched/package.lisp	2006-01-13 01:09:40.000000000 +0100
***************
*** 13,18 ****
--- 13,19 ----
  	   #:defmacro-clause #:defmacro-driver #:defclause-sequence
  	   #:initially #:after-each #:finally #:finally-protected
  	   #:else #:if-first-time
+            #:first-iteration-p #:first-time-p
  	   #:finish #:leave #:next-iteration #:next #:terminate
  	   #:repeat #:for #:as #:generate #:generating #:in
  	   #:sum #:summing #:multiply #:multiplying
Binary files global/iterate-1.4/sbcl-0.9.7-linux-x86/iterate.fasl and iterate-1.4-patched/sbcl-0.9.7-linux-x86/iterate.fasl differ
Only in iterate-1.4-patched/sbcl-0.9.7-linux-x86: iterate-test.fasl
Binary files global/iterate-1.4/sbcl-0.9.7-linux-x86/package.fasl and iterate-1.4-patched/sbcl-0.9.7-linux-x86/package.fasl differ




