Re: loop macro

From: Gregor.pa@Xerox.COM
I think I prefer "lispy" iteration macros. Here is an
example of what I mean by a lispy iteration macro:
;; Return a list of the items in list-of-items
;; which pass the test TEST.
(iterate ((item in list-of-items))
(when (test item)
(collect item)))
I once worked with a looping macro that looked like that -- with
lots of nested parens. The main problem with it is that, when you
look at the code, you tend to think that the (when ...) up there
is a function call rather than part of some loop. It's too context
dependent and rather confusing.
From: "Scott E. Fahlman" <Fahlman@C.CS.CMU.EDU>
3. The functionality of LOOP is fine, modulo some small
details, but the cute English-like syntax should be replaced
with something more Lispy. Specifically, parentheses should
be used to group the arguments controlling the various
major options rather than doing this with connecting words
like "by", "until", and "whereas". People in this group
feel pretty strongly that the little pseudo-sentences people
end up writing in the LOOP syntax are extremely confusing
and promote bad style. Things that aren't English shouldn't
look like English.
The mention of connecting words kind of puzzles me (and at the same
time helps me to understand the Lisp Machine loop macro). Our for
macro doesn't seem to need them (though it does use "by" and "until").
To explain how this works, let me give for's basic syntax:
(for [ let <let-var>* ]* ; <let-var> is <var> or (<var> <init>)
[ initially <form>* ]*
[ <iteration-spec>* ]* ; in, on, from, bind, being, etc
[ eachtime <form>* ]*
[ <termination-spec>* ]* ; while <form>* or until <form>*
[ <conditiion-spec>* ]* ; when <form>* or unless <form>*
[ <body-key> <form>* ] ; <body-key> is do, collect, etc
[ finally <form>* ] )
(I'll admit that not all of those *'s up there make a lot of sense
-- to understand them, imagine implicit progn's around them all.)
Each of those clauses stand alone -- there's no need to connect
them. In fact, you tend to think of the syntax as being "(for
<clause>*)". The from keyword does take by and to, but those are
part of the from clause. If the for was extended to handle more
than one body, then some of this neatness might disappear since
the when's and unless's would be associated with the next body
clause -- you'd want to indent the body clause more than the other
clauses and then the nice equality of clauses would not be as
strong... But, even then, you wouldn't need to add connectors.
I'm not trying to say that Common Lisp should necessarily adopt
the Maryland for as its looping construct. I just trying to say
that there ought to be some way to get rid of the concept of
connecting words without having to put parens around all the
clauses... Can the syntax for the Lisp Machine Loop be simplified
along these lines without losing big?
-Liz