[iterate-devel] Fwd: if-first-iteration, a little better version as an arch patch

Attila Lendvai attila.lendvai at gmail.com
Tue Jan 10 00:07:39 UTC 2006


> Actually, it's a critique of mine towards Iterate that I haven't yet identified a subset of primitives with which to write the many other Iterate clauses, and so that they work as efficiently as the predefined ones.  It's missing this "growing a language" concept.

As a small suggestion: I had trouble defining an internal named
variable on demand for if-first-iteration. I had to misuse
make-accum-var-binding with some (setf (cddr)) magic (could be it's
only because I'm new to lisp, but that setf is a hack compared to the
rest of the code).

> Indeed, I'm not yet using arch/tla.  For now it doesn't make much sense since I cannot (yet?) access common-lisp.net as a developer.
> Thanks for the info. I just recently jumped into darcs (cffi), but did not yet try out Arch or subversion.

We use darcs and it serves us well. Arch seems to be overcomplicated
at first glance.

And finally a new version of if-first-iteration:

(def-special-clause IF-FIRST-ITERATION (then &optional else)
  (setf then (list (walk-expr then)))
  (setf else (list (walk-expr else)))
  (let* ((step-body nil)
         (entry (make-accum-var-binding 'first-iteration t nil :type 'boolean))
         (first-iteration (first entry))
         (first-usage (not (third entry))))
    (when first-usage
      (setf step-body (list `(setf ,first-iteration nil)))
      (setf (cddr entry) (list t)))
    (return-code :body (list (if else
				 `(cond
				   (,first-iteration , at then)
				   (t , at else))
				 `(when ,first-iteration
				   , at then)))
		 :step step-body)))

bye,

- attila



More information about the iterate-devel mailing list