Iteratively evaluates bodys. The for-clauses
introduce bindings whose scope includes body and that
determine the number of times that body is evaluated.
A break-clause either among the for-clauses
or bodys stops further iteration.

In the simple case, each for-clause has one of its first two
forms, where [idseq-expr] is a shorthand for [(id)seq-expr]. In this simple case, the seq-exprs are evaluated
left-to-right, and each must produce a sequence value (see
Sequences).

The for form iterates by drawing an element from each
sequence; if any sequence is empty, then the iteration stops, and
#<void> is the result of the for expression. Otherwise
a location is created for each id to hold the values of each
element; the sequence produced by a seq-expr must return as
many values for each iteration as corresponding ids.

The ids are then bound in the body, which is
evaluated, and whose results are ignored. Iteration continues with the
next element in each sequence and with fresh locations for each
id.

A for form with zero for-clauses is equivalent to a
single for-clause that binds an unreferenced id to
a sequence containing a single element. All of the ids must
be distinct according to bound-identifier=?.

If any for-clause has the form #:whenguard-expr,
then only the preceding clauses (containing no #:when or #:unless)
determine iteration as above, and the body is effectively
wrapped as

using the remaining for-clauses. A for-clause of
the form #:unlessguard-expr corresponds to the same transformation
with unless in place of when.

A #:breakguard-expr clause is similar to a
#:unlessguard-expr clause, but when #:break
avoids evaluation of the bodys, it also effectively ends all
sequences within the for form. A #:finalguard-expr clause is similar to #:breakguard-expr, but
instead of immediately ending sequences and skipping the
bodys, it allows at most one more element from each later
sequence and at most one more evaluation of the following
bodys. Among the bodys, besides stopping the
iteration and preventing later body evaluations, a
#:breakguard-expr or #:finalguard-expr
clause starts a new internal-definition context.

In the case of list and stream sequences, the
for form itself does not keep each element reachable. If a
list or stream produced by a seq-expr is otherwise
unreachable, and if the for body can no longer reference an
id for a list element, then the element is subject to
garbage collection. The make-do-sequence sequence
constructor supports additional sequences that behave like lists and
streams in this way.

Iterates like
for, but that the last expression in the bodys must
produce a single value, and the result of the for/list
expression is a list of the results in order.
When evaluation of a body is skipped due to a #:when
or #:unless clause, the result list includes no corresponding
element.

Iterates like for/list, but results are accumulated into
a vector instead of a list.

If the optional #:length clause is specified, the result of
length-expr determines the length of the result vector. In
that case, the iteration can be performed more efficiently, and it
terminates when the vector is full or the requested number of
iterations have been performed, whichever comes first. If
length-expr specifies a length longer than the number of
iterations, then the remaining slots of the vector are initialized to
the value of fill-expr, which defaults to 0 (i.e.,
the default argument of make-vector).

Like for/list, but the result is an immutable hash
table; for/hash creates a table using equal? to
distinguish keys, for/hasheq produces a table using
eq?, and for/hasheqv produces a table using
eqv?. The last expression in the bodys must return
two values: a key and a value to extend the hash table accumulated by
the iteration.

Iterates like
for, but when last expression of body produces
#f, then iteration terminates, and the result of the
for/and expression is #f. If the body
is never evaluated, then the result of the for/and
expression is #t. Otherwise, the result is the (single)
result from the last evaluation of body.

Iterates like
for, but when last expression of body produces
a value other than #f, then iteration terminates, and
the result of the for/or expression is the same
(single) value. If the body is never evaluated, then the
result of the for/or expression is
#f. Otherwise, the result is #f.

Similar to for/list, but the last body expression
should produce as many values as given ids, and the result is
as many lists as supplied ids. The ids are bound to
the lists accumulated so far in the for-clauses and
bodys.

Iterates like
for, but after body is evaluated the first
time, then the iteration terminates, and the for/first
result is the (single) result of body. If the
body is never evaluated, then the result of the
for/first expression is #f.

Iterates like for. Before iteration starts, the
init-exprs are evaluated to produce initial accumulator
values. At the start of each iteration, a location is generated
for each accum-id, and the corresponding current accumulator
value is placed into the location. The last expression in
body must produce as many values as accum-ids, and
those values become the current accumulator values. When iteration
terminates, if a result-expr is provided then the result of the
for/fold is the result of evaluating result-expr
(with accum-ids in scope and bound to their final values),
otherwise the results of the for/fold expression are the
accumulator values.

An accum-id and a binding from a for-clause can be
the same identifier. In that case, the accum-id binding
shadows the one in a for-clause within the
body-or-break and body forms (even though,
syntactically, a for-clause is closer to to the body).

Defines id as syntax. An (id. rest) form is
treated specially when used to generate a sequence in a
for-clause of for (or one of its variants). In that
case, the procedure result of clause-transform-expr is called
to transform the clause.

When id is used in any other expression position, the result
of expr-transform-expr is used. If it is a procedure of zero
arguments, then the result must be an identifier other-id,
and any use of id is converted to a use of
other-id. Otherwise,expr-transform-expr must
produce a procedure (of one argument) that is used as a macro
transformer.

When the clause-transform-expr transformer is used, it is
given a for-clause as an argument, where the clause’s form is
normalized so that the left-hand side is a parenthesized sequence of
identifiers. The right-hand side is of the form (id. rest).
The result can be either #f, to indicate that the forms
should not be treated specially (perhaps because the number of bound
identifiers is inconsistent with the (id. rest) form), or a
new for-clause to replace the given one. The new clause might
use :do-in. To protect identifiers in the result of
clause-transform-expr, use for-clause-syntax-protect
instead of syntax-protect.

where body-bindings and done-expr are from the
context of the :do-in use. The identifiers bound by the
for clause are typically part of the ([(inner-id...)inner-expr]...) section.

The actual loop binding and call has additional loop
arguments to support iterations in parallel with the :do-in
form, and the other pieces are similarly accompanied by pieces from
parallel iterations.

3.18.3Do Loops

To initialize the loop, the init-exprs are evaluated in order
and bound to the corresponding ids. The ids are
bound in all expressions within the form other than the
init-exprs.

After the ids have been bound, the stop?-expr is
evaluated. If it produces #f, each expr is evaluated
for its side-effect. The ids are then effectively updated
with the values of the step-exprs, where the default
step-expr for id is just id; more
precisely, iteration continues with fresh locations for the
ids that are initialized with the values of the corresponding
step-exprs.

When stop?-expr produces a true value, then the
finish-exprs are evaluated in order, and the last one is
evaluated in tail position to produce the overall value for the
do form. If no finish-expr is provided, the value of
the do form is #<void>.