lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Title: Grupo Hasar
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 then

is 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 B

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).




Ing. Hugo Eduardo Etchegoyen
Gerente Dto. Software de Base

Compañía Hasar | Grupo Hasar
Marcos Sastre y José Ingenieros
El Talar. Pacheco
[B1618CSD] Buenos Aires. Argentina
Tel [54 11] 4117 8900 | Fax [54 11] 4117 8998
Visítenos en:
Información legal y política de confidencialidad: