ITERATE use (was Re: [cl-typesetting-devel] CLISP support)

Marc Battyani marc.battyani at fractalconcept.com
Tue Apr 27 20:54:43 UTC 2004


"Klaus Weidner" <kw at w-m-p.com> wrote:

> On Tue, Apr 27, 2004 at 08:34:35PM +0200, Marc Battyani wrote:
> > "Klaus Weidner" <kw at w-m-p.com> wrote:
> > > The implementations seem to agree on everything other than that.
> >
> > No, there is also the sequential vs global tests. Where CLisp differs
from
> > the other ones.
>
> I'm not sure what you mean by that - the changes I did regarding in-loop
> and on-loop etc. were all related to getting the expected iteration
> variable value into the FINALLY clause. If the code had not cared about
> those, there would have been no need for a change - the values always
> matched while inside the loop body itself.

No, you still don't grok loop. ;-) (The CLISP guys neither)
Loop is simple though:
You execute the clauses in sequence. For each close you set the variable,
execute the test, if it fails you go to the epilog. That's all.

> The maximized NIL value was a separate issue and a real bug in the code
> that depended on the implicit 0 initialization done by MIT LOOP.

We agree on that point. :)

> > > It's Marc's decision - I can live with either one. I'd suggest
reducing
> > > the complexity of loops of either kind if at all possible, similar in
> > > spirit to the v-split change I made.
> >
> > Still don't like LOOP heh...  ;-)
>
> You caught me... This entire episode didn't exactly endear it to me. I
> learned more about it than I originally wanted to, and I'm not sure if
> that was a good thing.
>
> > But I agree that loops should keep a reasonable size.
>
> Thanks, then I don't think it'll be a problem. The complex ones are just
> IMHO hard to debug and experiment with.
>
> > A good point in favor of ITERATE is that the semantics can be precisely
> > defined and implemented. I discussed with Andreas and he is open to
modify
> > it and the associated doc so that it is really usable.
>
> Note that the FINALLY values are also the rather weird MIT LOOP ones in
> ITERATE:
>
> (iter (for i :from 0 :below 2)
>       (for j :from 0 :below 2)
>       (finally (return (list i j))))
> => (2 1)

Sure nice isn't it ?
I discussed with Andreas and he is ok to keep and document this behavior :)

> So even if this behavior is documented and dependable, I still would not
> consider it to be good style to write code that uses those values.

It's not a really good style but it's natural. The clause variables don't
vanish during the epilog.

> > A bad point is that it is not standard. So this will make the sources
less
> > readable for others.
>
> I don't think that it's such a big deal - if you mentally remove some
> parentheses it looks much like LOOP, with some standard Lisp expressions
> intermingled. I think it's far cleaner to be able to use standard if/when
> inside ITER rather than the weird pseudo-Lisp LOOP variants.

Yes, the conditionals and the grouping of LOOP clauses by AND are ugly and
not lispy. (At least one point of agreement ;-)
And the simple ITERATE clauses are the same as the LOOP ones so they are
understandable.
Also there is a mean to get the previous iteration value (I'm sure you won't
like that one) and that alone is great!

> > BTW Andreas has put a new version of ITERATE with a postscript manual. I
> > will try to look at it this evening.
>
> I had read the included "Iterate Manual" MIT report this weekend, and I
> like it a lot. As far as I can tell it also doesn't specifically say
> anything about values of iterate vars in FINALLY clauses ;-)

Next release ;-)

I've also quickly read the manual and I am rather in favor of ITERATE.

Anybody else has an opinion on the subject ?

Marc





More information about the cl-typesetting-devel mailing list