1.1 About the Loop Facility

1.1.2 Differences between LOOP and DO

There are important differences between the Loop Facility and the Common Lisp macrodo. The Loop Facility provides clauses that control iteration behavior in different ways. For example, you can iterate until the end test evaluates tonil by using the loop constructwhile, and you can iterate until the end test has a non-nil value by using the loop constructuntil. Thedo macro terminates when the result of its end test is non-nil.

Some iteration operations occur frequently in Common Lisp code; for instance, you often need to sum values, iterate through a list, collect items into a list, or find a maximum or minimum value. The Loop Facility provides support for these common operations with such constructs assum,count,collect,maximize, andminimize. Thedo macro provides no such support for these operations; you must code the desired functionality into the loop explicitly.

The Loop Facility also provides predefined extensions for iteration over commonly used data structures. For example, you can iterate over items in a hash table or over characters in a string.

However, you can achieve the same iteration results from thedo macro that you can with the Loop Facility. The following examples illustrate the programming differences. - Example 1 - Example 2 - Example 3

The Loop Facility - 9 SEP 1996

Generated with Harlequin WebMaker