Exactly.
Like I mentioned before, I'm the poor schmuck that has to clean it up because someone didn't bother to take your (common sense) advice years ago.
http://www.csd.uwo.ca/~yuri/Papers/pami04.pdf
It's really great, for the record. Anyway, the algorithm they wrote uses an early exit. In fact, they use a while(true), the "worst case" example.
initialize: S = {s}, T = {t}, A = {s, t}, O = {(Empty Set)}
while true
grow S or T to find an augmenting path P from s to t
if P = {(Empty Set)} terminate
augment on P
adopt orphans
end while
In programming this algorithm, sure, I could probably move the first grow before the loop, and grow at the end. But, now its harder to understand, and violates the afore mentioned copy paste rule.My point is this, take any such "rule" with a grain of salt. There are plenty of examples where it makes sense to do something atypical.
Put it in a common function. Sure, it may look a little frazzled today, but generations of future hackers will thank you.
while(readLine()) { process lines... }
where readLine() encapsulates the repetition and returns eof as well.
I was trying to point out that the idiom becomes while(line=readline()) which I'd rather avoid since = and == often get confused in a conditional.
It would normally be silly to get into this level of detail but I use this so often.
Which is more expensive, a few milliseconds of machine time a few million times or a whole bunch of human time once or twice?
Wow. Not every problem calls for recursion. If you really hate early exits from loops, maybe you should just code the loop's condition differently.