To write constraints on component or attribute arrays, we need a construct for writing loops. DJ has a for statement for this purpose. A for statement has the following form:
for (EnumeratorConstraint,...,EnumeratorConstraint) Constraint;where EnumeratorConstraint is a domain constraint in the form of var in D, or an arithmetic constraint. Let Vars be the set of variables apprearing in all the enumerator constraints. This statement means that for each tuple of values for vars that satisfies the enumerator constraints, Constraint must be satisfied.
For example, the component declaration:
component Label lbs[3]{{text == "zero"}, {text == "one"}, {text == "two"}};can be defined equivalently as follows:
component Label lbs[3]; for (i in 0..2) { i==0 -> labs[i].text == "zero"; i==1 -> labs[i].text == "one"; i==2 -> labs[i].text == "two"; }
When an enumerator constraint is an arithmetic constraint that cannot be tested because the variables involved have not yet been sufficiently instantiated, then the evaluation will be delayed until the constraint is testable.