lua-users home
lua-l archive

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


>  IMO the 'single exit point' rule is not a good idea.

This is a matter of taste.

Please note that I'm just submitted my 2c for statictics sake. I'm not
trying to convert anyone in my belief :)

Also I have no strong arguments for not adding continue or removing
repeat/until to the language. As long as their existance does not
force me to use them :)

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

Such amount of nested ifs is a "bad smell" -- that code should
probably be split to separate functions etc.

>  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
>      A
>  else
>      B
>  end
>  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
>  A

I *personally* find this less readable. But, again, this is a matter
of taste and habit.

Alexander.