first-time-p bugfix: return-code :body must return list of forms
Fri May 25 07:15:33 PDT 2007 Joerg-Cyril Hoehle <hoehle@users.sourceforge.net>
* first-time-p bugfix: return-code :body must return list of forms
if-first-time not declared obsolete
documentation strings for (iter:display-iterate-clauses) complete
diff -rN -u old-iterate/doc/iterate.texinfo new-iterate/doc/iterate.texinfo
--- old-iterate/doc/iterate.texinfo 2014-07-13 07:03:46.000000000 -0700
+++ new-iterate/doc/iterate.texinfo 2014-07-13 07:03:46.000000000 -0700
@@ -1251,7 +1251,7 @@
@clauseu{first-iteration-p}
@deffn Clause first-iteration-p
-Returns @code{t} in the first cycle of the loop, otherwise @code{nil}.
+Returns @code{t} in the first iteration of the loop, otherwise @code{nil}.
@end deffn
@clauseu{first-time-p}
diff -rN -u old-iterate/iterate.lisp new-iterate/iterate.lisp
--- old-iterate/iterate.lisp 2014-07-13 07:03:46.000000000 -0700
+++ new-iterate/iterate.lisp 2014-07-13 07:03:46.000000000 -0700
@@ -2354,16 +2354,23 @@
(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
+;;; (IF-FIRST-TIME then &optional else)
+(def-special-clause if-first-time (then &optional else)
+ "Evaluate branch depending on whether this clause if met for the first time"
+ (return-code :body (list
+ (if-1st-time (list (walk-expr then))
+ (if else (list (walk-expr else)))))))
+
+;;; (FIRST-TIME-P)
(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)))))
+ "True when evaluated for the first time"
+ (return-code :body (list (if-1st-time '(t)))))
-;;; (if (FIRST-ITERATION-P) ...) returns true in the first iteration of the loop
+;;; (FIRST-ITERATION-P)
(def-special-clause FIRST-ITERATION-P ()
+ "True within first iteration through the body"
+ ;; Like (with ,var = t) (after-each (setq ,var nil))
+ ;; except all these clauses shares a single binding.
(let* ((entry (make-shared-binding 'first-iteration t :type 'boolean))
(step-body nil)
(first-usage (not (cddr entry)))
@@ -3597,12 +3604,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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: