These are primarily useful for writing drivers that can also be used as generators (see Generators).
var is set to expr each time through the loop. Destructuring is performed. When the clause is used as a generator, expr is the code that is executed when
)is encountered (see Generators). expr should compute the first value for var, as well as all subsequent values, and is responsible for terminating the loop. For compatibility with future versions of
iterate, this termination should be done with
terminate, which can be considered a synonym for
finish(see Control Flow).
As an example, the following clauses are equivalent to
(for i from 1 to 10):(initially (setq i 0)) (for i next (if (> i 10) (terminate) (incf i)))
form is evaluated each time through the loop. Its value is not set to var; that is form's job. var is only present so that
iterateknows it is a driver variable.
)is equivalent to
do-next (dsetqvar expr
)). (See Destructuring for an explanation of