One nice property with (pure) structured programming is that the statement
do {
...
} while (p);
guarantees that p is false after the loop and this makes it easier to reason about the program. With breaks, however, the loop could be "lying" so to speak.Agreed. I think it's also a little easier to understand what's going on when stepping through the code in a debugger.
Re:Source code for Quake 2 rerelease
by another2another on Friday August 11, 2023 @09:02AM
(#37088222)
For me the original is much clearer and is how I normally structure my iterators/do/for loops, since explicitly checking for conditions and using 'continue' when the iterated value is not worth processing makes it nice and clear that everything _after_ these checks is valid and can contain the meat of the processing without more if/else checks.
This approach also works fine for c++ and c# code (probably also java too), which I like as it keeps my projects nice and consistent and I can jump between codebases and feel at home.
The only thing that I don't like about it is the if() statements not being contained in {}'ies. That always makes me nervous.
I'd say I prefer the original.