"They also don't allow goto. The problem with the three of them is that they disrupt the flow of the code for someone reading it. You are supposed to put everything into the conditions for the loop. It seems to me that there are times when a few continues or breaks in if statements are easier to read than a long and convoluted loop condition. Yes, some situations could be covered in the loop conditions just as easily as with a break or continue, but every now and then, break and continue are much easier."

I got this from another forum. But are break and continue generally frowned upon because of that?

8 Years
Discussion Span
Last Post by Salem

>But are break and continue generally frowned upon because of that?
Some people frown on break and continue because they don't see them as "pure" structured programming techniques. These people are generally too weak willed to use the best solution available or lack real-world experience where purity is, more often than not, a liability.

If the coding guidelines you're required to use prohibit them, then you should follow the guidelines. But for your own style, I recommend fully understanding how and when goto, break, and continue are best used, and deciding for yourself if they should be.


That depends on your coding standards. MISRA C for example disallows all of them except break; in the context of a switch statement.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.