|
|
|
|
|
by mehrdadn
2065 days ago
|
|
Oh! I thought bounded loops meant every loop has to have a bound (hence while (true) wouldn't work). If it can handle more complicated situations then that answers my question. The second example is identical to a do-while loop though, so it's not clear to me if it can actually handle more complicated situations that don't directly map to for/while/do-while loops. For example, can it handle something like the following, where there's no bound, but the loop necessarily always terminates? (I assumed this loop would be called "unbounded", but maybe I'm confused by the terminology?) int test(unsigned i, unsigned j) {
while (true) {
i ^= j; j ^= i; i ^= j;
if (i <= j) { return 0; }
i ^= j; j ^= i; i ^= j;
if (j <= i) { return 1; }
i ^= j; j ^= i; i ^= j;
}
return 2;
}
|
|