On Tuesday, 22 July 2014 at 16:42:14 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Tue, Jul 22, 2014 at 03:52:14PM +0000, Vlad Levenfeld via
Digitalmars-d-learn wrote:
Anyway my actual question is: if all values are constant at
compile
time, how would a static while loop terminate?
Basically, think of it as custom loop unrolling:
TypeTuple!(
int, "x",
float, "y",
uint, "z"
) t;
// This loop:
foreach (i; staticIota(0, 3)) {
t[i]++;
}
// Is equivalent to:
t[0]++;
t[1]++;
t[2]++;
// Which is equivalent to:
t.x++;
t.y++;
t.z++;
The loop body is basically expanded for each iteration, with
the loop
variable suitably substituted with each element of the typelist.
You're misunderstanding him. Your example is a static foreach,
but Vlad asked about static while. I too don't see how a static
while is supposed to work.