July 31, 2002
Loop is not Pretty

KMP on loop:

The paradox of LOOP is that if you confine yourself only to the loops that look stylistically clean and simple (which are the ones that Smalltalk probably does well), you get a subset that would never have caused LOOP to come into existence in the first place. Like it or not, LOOP was invented to allow you to write the complex stuff that is hard to express in terms of simple functional iterators because the control structure is a tangle.

KMP gets philosophical:

The world is not always pretty. When it is, one must not blame the lack of prettiness on the language that tries to emulate it. Sometimes tangled webs of reality lead to tangled webs in programs.

That may be one of those initially-depressing, eventually-uplifting sorts of realizations. I still don't use loop (but at least now I'm better prepared to justify it to myself if I do).

Posted by jjwiseman at July 31, 2002 09:06 AM

I do use LOOP. I started my LOOP exploration journey after realizing that this feature is the outcome of extensive experimentation, experience, discussion and wisdom, both within the Lisp community and the ANSI X3J13 committee. Its current state is the result of a sound engineering tradeoff, not the obsessive quest for some abstract idea of purity or the chase of a fad.

Posted by: Paolo Amoroso on August 1, 2002 07:13 AM

Eh, I dunno. I still really like Series and Iterate, both of which I feel are superior to Loop.

Posted by: Paul Snively on August 2, 2002 08:47 AM

Loop is no extremely pretty, but it is more mnemonic than DOs and easier to work out a complex iteration construct than in functional iteration packages.

(IMHO, of course)

Posted by: Eugene Zaikonnikov on August 2, 2002 11:31 AM

I like the extended LOOP, but there tends to be a complexity threshold at which I tend to back off and find another approach (quite often a simple LOOP with some conditionals and RETURN forms). Usually it's when I would otherwise find myself using FINALLY. When it gets to that level I can't keep the return values straight.

But what other iteration construct lets you write

* (loop for (i j) on (list 1 2 3 4 5 6 7 8 9 10) by #'cddr collect (cons i j))

That's worth the price of admission on its own.

Posted by: Daniel Barlow on August 2, 2002 04:46 PM
Post a comment

Email Address:


Unless you answer this question, your comment will be classified as spam and will not be posted.
(I'll give you a hint: the answer is “lisp”.)


Remember info?