anchor.diff:     (initially :initform nil :accessor initially)
      (finally :initform nil :accessor finally)
      (during-first :initform nil :accessor during-first)
  +   (first-guard :initform nil :accessor first-guard)
      (during-last :initform nil :accessor during-last)
  +   (last-guard :initform nil :accessor last-guard)
      (default-accum-var :initform nil :accessor default-accum-var)
      (default-accum-kind :initform nil :accessor default-accum-kind)
      (body :initform nil :accessor body)))
  
positive.code:         (loop :while (tokens state) :do (clause state))
          (nreverse-loop-state state))))
  
  (defun init-forms (loop)
    (mapcar (lambda (x) (subseq x 0 2)) (iterations loop)))
  
  (defun step-forms (loop)
    (mapcar (lambda (x) `(setf ,(first x) ,(third x))) (iterations loop)))
  
  (defun end-test (loop)
    (aif (loop :for (nil nil nil test) :in (iterations loop) :when test :collect test)
         (if (cdr it)
             (list 'not (cons 'or it))
             (cons 'not it))
         '(not nil)))
  
  (defpsmacro loop (&rest args)
    (let* ((loop (parse-ps-loop (normalize-loop-keywords args)))
           (first-guard (and (during-first loop) (ps-gensym)))
           (last-guard (and (during-last loop) (ps-gensym))))
      `(,@(if (default-accum-var loop) '(with-lambda ()) '(progn))
          ,@(when (during-first loop) `((var ,first-guard t)))
          ,@(when (during-last loop) `((var ,last-guard nil)))
          ,@(prologue loop)
          ,@(initially loop)
          (for ,(init-forms loop)
            (,(end-test loop))
            ,(step-forms loop)
            ,@(when (during-first loop)
                    `((when ,first-guard
                        ,@(during-first loop)
                        (setf ,first-guard nil))))
            ,@(body loop)
            ,@(when (during-last loop)
                    `((setf ,last-guard t))))
          ,@(when (during-last loop)
                  `((when ,last-guard ,@(during-last loop))))
          ,@(finally loop)
          ,@(when (default-accum-var loop) `((return ,(default-accum-var loop)))))))
  
negative.code:     (:maximize `(setf ,var (if (null ,var) ,term (max ,var ,term))))
      (:collect `((@ ,var :push) ,term))))
  
  (defun first-time-clause (state)
    (push (eat state :progn) (during-first state))
    (unless (first-guard state)
      (setf (first-guard state) (ps-gensym))))
  
  (defun last-time-clause (state)
    (push (eat state :progn) (during-last state))
    (unless (last-guard state)
      (setf (last-guard state) (ps-gensym))))
  
  (defun repeat-clause (state)
    (let ((index (ps-gensym)))
      (setf (tokens state) (append `(,index :from 0 :below ,(eat state)) (tokens state)))
  