[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: I'd give my right arm for a continue statement
- From: Steve Litt <slitt@...>
- Date: Sun, 23 Jan 2011 16:56:25 -0500
On Sunday 23 January 2011 16:28:10 Enrico Colombini wrote:
> On 23/01/2011 21.26, Steve Litt wrote:
> > Speaking personally just for myself, I really hate that extra level of
> > indentation. For me personally, the more levels of branching I have, the
> > likelier errors become.
>
> Could be, but I feel that having multiple endpoints in a loop due to the
> presence of gotos (e.g. break, continue) can be far worse for
> readability and maintenance, especially for non-trivial functions.
>
> So I didn't use them in the last 30 years or so and I simply do not miss
> them (nor do I miss flowcharts...)
I understand completely. Break and continue are gotos -- spaghetti code. If
used very locally on small loops they're not a problem and can reduce the need
for huge, compound boolean tests and an extra level of indentation. But you're
right -- as more and more code is added to the loop, the typical goto risks go
way up.
Probably the reason that "relevant lines" workaround even occurred to me is at
Santa Monica Community Colleges they demanded we go 100% structured, and of
course I was using Pascal so it's hard not to go structured. So as a student I
developed algorithms that skipped past non-relevant lines.
I'll still say this: If, and that's a big if, break and continue are used
wisely and in the right circumstances, they can yield big readability gains.
And you're right -- if used wrong they're an atrocity.
SteveT
Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt