diff -cr global/iterate-1.4/iterate.lisp iterate/iterate.lisp
*** global/iterate-1.4/iterate.lisp	2005-06-23 15:21:31.000000000 +0200
--- iterate/iterate.lisp	2006-02-09 00:20:37.000000000 +0100
***************
*** 255,260 ****
--- 255,266 ----
  
  (defvar *accum-var-alist*)
  
+ ;;; Shared variables created by make-shared-binding.
+ ;;; It's an alist of (name gensym-var <possibly other info>).
+ ;;; Tipical use is FIRST-ITERATION-P.
+ 
+ (defvar *shared-bindings-alist*)
+ 
  ;;; Name of the block for this iterate form.  Used in generating
  ;;; return statements.
  
***************
*** 538,543 ****
--- 544,550 ----
  	 (*declarations* nil)
  	 (*loop-body-wrappers* nil)
  	 (*accum-var-alist* nil)
+          (*shared-bindings-alist* nil)
  	 (*top-level?* t)
  	 (*binding-context?* nil)
  	 (*temps* nil)
***************
*** 1751,1757 ****
        (check-internal-variables var)
        entry))))
  
! 
  
  (defun make-binding-internal (var-spec value value-supplied? 
  				       use-type using-type-of)
--- 1758,1772 ----
        (check-internal-variables var)
        entry))))
  
! (defun make-shared-binding (var value &key type using-type-of)
!   "Look up or create an alist entry keyed by var, store a gensym
!    in the value and also add it as a binding. Return the entry."
!   (let ((entry (assoc var *shared-bindings-alist* :test #'eq)))
!     (unless entry
!         (setq entry (list var (gensym (string var))))
!         (push entry *shared-bindings-alist*)
!         (make-binding (second entry) value :type type :using-type-of using-type-of))
!     entry))
  
  (defun make-binding-internal (var-spec value value-supplied? 
  				       use-type using-type-of)
***************
*** 2318,2327 ****
    (mapc #'local-binding-check forms)
    (return-code :final-protected (copy-list forms)))
  
! ;;; (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))))))
  
  ;;; (IN &body)
  (def-special-clause in (block-name &rest forms)
--- 2333,2357 ----
    (mapc #'local-binding-check forms)
    (return-code :final-protected (copy-list forms)))
  
! ;;; (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* ((entry (make-shared-binding 'first-iteration t :type 'boolean))
!          (step-body nil)
!          (first-usage (not (cddr entry)))
!          (var (second entry)))
!     (when first-usage
!       (setf step-body (list `(setf ,var nil)))
!       (setf (cddr entry) (list t)))
!     (return-code :body `(,var)
!                  :step step-body)))
  
  ;;; (IN &body)
  (def-special-clause in (block-name &rest forms)
***************
*** 3552,3557 ****
--- 3582,3593 ----
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; Junk.
  
+ ;;; Obsolete, use (if (first-time-p) ...)
+ ;;; (IF-FIRST-TIME then &optional else)
+ (def-special-clause if-first-time (then &optional else)
+   (warn "if-first-time is obsolete, use (if (first-time-p) ...) instead")
+   (return-code :body (list (if-1st-time (list (walk-expr then))
+                                         (list (walk-expr else))))))
  
  ;;;;;;; For Gnu Emacs ;;;;;;;
  ;;; Local variables:
diff -cr global/iterate-1.4/iterate-test.lisp iterate/iterate-test.lisp
*** global/iterate-1.4/iterate-test.lisp	2005-06-23 13:32:32.000000000 +0200
--- iterate/iterate-test.lisp	2006-01-29 23:14:20.000000000 +0100
***************
*** 922,927 ****
--- 922,945 ----
  	    (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)
diff -cr global/iterate-1.4/package.lisp iterate/package.lisp
*** global/iterate-1.4/package.lisp	2005-06-23 15:19:26.000000000 +0200
--- iterate/package.lisp	2006-02-08 23:27:20.000000000 +0100
***************
*** 12,18 ****
  	   #:defsynonym #:dsetq #:declare-variables
  	   #:defmacro-clause #:defmacro-driver #:defclause-sequence
  	   #:initially #:after-each #:finally #:finally-protected
! 	   #:else #:if-first-time
  	   #:finish #:leave #:next-iteration #:next #:terminate
  	   #:repeat #:for #:as #:generate #:generating #:in
  	   #:sum #:summing #:multiply #:multiplying
--- 12,18 ----
  	   #:defsynonym #:dsetq #:declare-variables
  	   #: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
