🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2149

Re: use of the break statement

#2149
From: Art Shelest
Date: Fri, 01 Mar 1996 23:33
31 lines
1612 bytes
In article <4gnbcp$biq@solutions.solon.com>,
   Network News <news@dcs.warwick.ac.uk> wrote:

>In code that I write, and see, every day, break is very commonly used
>to exit a loop.  In fact, I sometimes have a break being the /only/ way
>to exit a loop.
~~~~~~~~~~~~~~~~
>
>-zefram

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.


   _Art.
Technical Details
Message-ID: <4h81gh$aql@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4gfcl7$2ls@solutions.solon.com> <4gnbcp$biq@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: Artyom@kansmen.com (Art Shelest)
Newsgroups: comp.lang.c.moderated
Subject: Re: use of the break statement
Date: 1 Mar 1996 17:33:36 -0600
Organization: Kansmen Corp.
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4h81gh$aql@solutions.solon.com>
References: <4gfcl7$2ls@solutions.solon.com> <4gnbcp$biq@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: News Xpress Version 1.0 Beta #4