[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iteration discussion



The iteration discussion died down as soon as it got "moved" to the
iteration distribution list. Perhaps this subcomittee doesn't have the
right membership. Here are some thoughts on iteration primitives which I
composed several weeks ago:

How legible the keyword style is depends in part upon how well the
editor/pretty printer deals with them. The keywords aren't "cute",
they're taken directly from some of the more commonly used "other"
programming languages around.

It is generally a bad idea to use very similar syntax to mean different
things in different contexts. Since Common-Lisp uses "when" and "unless"
as macros for variations on "if", it isn't good style to use them in
loop, even though their use was natural in Interlisp (and, for history
buffs, the Lisp/360 version which preceded it.)

The most powerful application of the iteration primitives is the ability
to define new iterators. It's disappointing that most of the Interlisp
follow-ons left that feature out. We've found much application, e.g., in
the ability to define ikterators which map over files or packages or
lists or what-have-you.  If done carefully, most of the intrinsic
complexity of "loop" can be reduced, by having a kernel of predefined
keywords and a simple way of extending the syntax.

It is likely that if there had been a powerful iteration construct that
the sequence functions would could have been omitted from the language.
The converse is also true:

We could enhance the sequence functions using CommonLoops if we define
default implementations for them which use only the methods that all
ordered collections must follow, and then include new classes for
Interval. This is the approach used successfully in Smalltalk for
dealing with iteration, e.g.,

(map #'print (interval 3 6))

vs (loop for x from 3 to 6 collect (print x)).

Unfortunately, taking this approach would defer any decision on
iteration until after some decision on object-oriented programming, and
might have performance considerations that some folks would consider
unacceptable.