|
IMO the 'single exit point' rule is
not a good idea. Pascal enforced that rule and the result is tedious programs with lots of nested ifs overflowing the right margin. I personally find it difficult to follow a program's logic beyond the third level of nested ifs. Anyway, 'break' and 'return' already break that rule in much stronger ways than 'continue', since 'continue' just exits the loop body, while 'break' exits the enclosing loop and 'return' exits the enclosing function. IMO the judicious use of control-breaking constructs makes a program more readable and easier to understand by presenting the main flow of control at a single indentation level while using the lateral exits for handling exceptional situations. As with everything else, abuse should be avoided. If C is a condition that may reasonably hold or not, then the construct if C thenis the natural way to code it, since A and B have the same logical hierarchy. But if C should normally hold and B handles an exceptional case, then IMO this is better: if not C then [continue, break, return, throw, etc.] end --> jumps to BHE Alexander Gladysh escribió: My 2c: I find that I almost _never_ use "continue" (maybe once a year). I use "repeat...until" [or its C analogue] kind of rarely too, but more often than continue.Same here. Continue contradicts with my understanding of single exit point idiom. And repeat...until... I used it may be once in all time I use Lua (and I can't even remember why). 2c. Alexander. --
Ing.
Hugo Eduardo Etchegoyen Compañía
Hasar | Grupo
Hasar |