Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-07 7:58
This is a construct that is very useful to avoid either a redundant check or a
...becomes...
where the intent is for statements in a
Discuss.
goto. This...for(a;b;c) {
expr1;
if(d) {
expr4;
goto done;
}
expr2;
}
expr3;
done:...becomes...
for(a;b;c) {
expr1;
if(d) {
expr4;
break;
}
expr2;
} done {
expr3;
}where the intent is for statements in a
done clause immediately following a loop to be executed if and only if the loop was exited via its termination condition being reached. This also generalises for while() and do-while, here using some common examples.while(*j) {
if(*j++ == k) {
u = v + k;
break;
}
} done
u = v - k;do {
if(f(a[i]))
break;
} while(a[i++]) done {
g();
}Discuss.