[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: upcoming changes in Lua 5.2
- From: "Alexander Gladysh" <agladysh@...>
- Date: Tue, 26 Feb 2008 17:19:04 +0300
> 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.
- References:
- Location of a package, Ignacio Burgueño
- Re: Location of a package, eugeny gladkih
- upcoming changes in Lua 5.2 [was Re: Location of a package], Roberto Ierusalimschy
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Shmuel Zeigerman
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Roberto Ierusalimschy
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Asko Kauppi
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Doug Rogers
- Re: upcoming changes in Lua 5.2, Miles Bader
- Re: upcoming changes in Lua 5.2, Alexander Gladysh
- Re: upcoming changes in Lua 5.2, Hugo Etchegoyen