A for-each-statement is introduced with 'for' and it executes
the loop body for all elements of an array. The Seed7
library "array.s7i" contains the following definition of the
for-each-statement:
const proc: for (inout baseType: variable) range (in arrayType: arr_obj) do
(in proc: statements)
end for is func
local
var integer: number is 0;
begin
for number range minIdx(arr_obj) to maxIdx(arr_obj) do
variable := arr_obj[number];
statements;
end for;
end func;
The type arrayType is an array of baseType elements.
The local integer variable 'number' is declared
and initialized with an integer literal.
A for-statement is used to execute the loop body for all values of 'number' between minIdx(arr_obj) and maxIdx(arr_obj).
The syntax of the for-each-statement is declared in the library "syntax.s7i" as:
$ syntax expr: .for.().range.().to.().do.().end.for is -> 25;
Additionally everybody can overload the for-each-statement also. Because of this powerful features it is not necessary to use iterators.