<conditional inside loop>=
...loop control stuff...
if (x) {
<Do this>
}
else {
<Do that>
}
...more loop control stuff...
To avoid the if, without noweb, I would make two copies of the loop
control code, one with <Do this> inside, the other with <Do that>
inside, and with the if statement outside of the loop. But that means
maintaining two copies of identical loop control code, which is
unacceptable. So instead I do this:
<conditional outside loop>=
if (x) {
<Do this loop>
}
else {
<Do that loop>
}
<Do this loop>= (<-U) #define WANT_TO_DO_THIS <Generic loop> #undefine WANT_TO_DO_THIS
<Do that loop>= (<-U) #define WANT_TO_DO_THAT <Generic loop> #undefine WANT_TO_DO_THAT
<Generic loop>= (<-U <-U) ...loop control stuff... #ifdef WANT_TO_DO_THIS <Do this> #endif #ifdef WANT_TO_DO_THAT <Do that> #endif ...more loop control stuff...
So I end up in the tangled source with two copies of the loop control code, just like I would have to do by hand without noweb, but I only have to maintain one copy. Couldn't do it without LitProg.