Possible Duplicate:
Break statements In the real world
Some days ago I started a quick open source project and, when some mates looked at the code on svn, one of them told me that using break
statement inside a for
loop is considered harmful and shouldn't be done.
He added, though, that I would find several cases of break
statements inside for
loops on Linux kernel source code, but that was just because only Linus Torvalds and Chuck Norris were allowed to use it and no one else.
What do you think? I see no problem in using break
inside a for
loop. In my opinion, emulating the behaviour of break
using boolean variables or something alike adds a lot of innecesary overhead and makes the code less straightforward.
Also, there's no room for comparison with goto
, because break
cannot arbitrarily change program's flow from one point to the other lie goto
does.