Article View: comp.lang.c.moderated
Article #2156Re: use of the break statement
From: Gene Wirchenko
Date: Sat, 02 Mar 1996 14:40
Date: Sat, 02 Mar 1996 14:40
44 lines
2246 bytes
2246 bytes
Artyom@kansmen.com (Art Shelest) wrote:
[snipped others']
>There's a trivial conversion (best viewed with fixed pitch font):
> BOOL bBreak = FALSE;
>while(..) while(!bBreak && .. )
>{ {
> ...// text1 ...//text 1
> if( condition ) bBreak = condition;
> break; if( !bBreak )
> {
> ...// text2 ...// text 2
>} }
> }
>I'm not saying that right side is prettier, just that such conversion is
>always possible. In face, you can write such a convertor and run your
>"breakful" code through it just before code reviews.
>Enclosing the loop in a set of { } brackets would localize bBreak.
Of course it is always possible. It is also possible for the
right-hand side to be machine language. This does not mean that
everyone should abandon HLLs.
The left-side is clearer. Please view this in connection with
another ?principle of programming: procedures should not be long.
Some say a page. I say two (as I comment and blank line more). At
any rate, there will not be a long walk to the end of the loop. When
I examine code, one of the first things I do is to delineate the
nesting. It's a relief when the structure is simple and does not have
a lot of nesting. break aids this simplicity.
> _Art.
Sincerely,
Gene Wirchenko
C Pronunciation Guide:
y=x++; "wye equals ex plus plus semicolon"
x=x++; "ex equals ex doublecross semicolon"
Technical Details
Message-ID:
<4h9ml2$gub@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4gfcl7$2ls@solutions.solon.com> <4gnbcp$biq@solutions.solon.com> <4h81gh$aql@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: genew@mindlink.bc.ca (Gene Wirchenko) Newsgroups: comp.lang.c.moderated Subject: Re: use of the break statement Date: 2 Mar 1996 08:40:34 -0600 Organization: MIND LINK! - British Columbia, Canada Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4h9ml2$gub@solutions.solon.com> References: <4gfcl7$2ls@solutions.solon.com> <4gnbcp$biq@solutions.solon.com> <4h81gh$aql@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com X-Newsreader: Forte Free Agent 1.0.82