Hi.
Quote:
Originally Posted by
Ygor
Using "break" violates good programming standards because it breaks the "single-entry single-exit" rule for control structures.
I'm not so sure about this claim. There is still a single exit at the bottom of the while, and how you get there seems to be the issue here. I would take the meaning of
multiple-exit to be that there would be a place to which control is transferred without explicitly traveling through the end of the while, just as
multiple-entry would mean entering the body of the while without going through the top of the while. (For precision I suppose we could say
the statement immediately after the end of the while instead of the end of the while itself.)
In any case, I tend to lean toward making understanding and maintenance easy, so readability counts for a lot:
Quote:
For pragmatists, I think it's important to notice that even Dijkstra(as I recall) and Wirth (definitely) admit that there are certain circumstances when GOTOs are best practice: to exit deeply nested structures (of IFs/FORs/WHILEs) in case of unrecoverable error, because doing so with a goto results in far more readable code than does the same code rewritten to test for FATAL_ERROR everywhere.
--
Goto Considered Harmful
I enjoy these Dharma-duels (as long as they don't get out of hand, and I think I will be a grasshopper for long time) ... cheers, drl