If you don't mind loops containing multiple break statements, then the only problem here is that C (for obvious reasons) doesn't allow you to break out of the bare block, hence the βnon-loopβ, which is some kind of unsuspecting future the maintainer could be wrong for the real cycle.
Considerations, I think, are as follows:
- if there are only two
break points, what's bad about the two if ? - if there are more than two breakpoints, then indentation with
if can become unpleasant, and this saves it, but again, does the function do too much? And even if this is not the case, would it be better to just use goto and avoid the weirdness of a loop that doesn't loop?
Since you put this agnostic language, I used the mock assembler language with block ... endblock from which you could break out. This leads to reasonably good code for checking the necessary conditions, for example:
block breakif str1 == null breakif str2 == null get some combined property of str1 and str2 breakif some other condition that stops us getting on with it get on with it endblock
Actually it was not breakif str1 == null , it was breakifeq.p str1, null , or something like that, but I forgot exactly what.
source share