220 3620 <4f808b69-07f9-4bc6-8466-335f77c1989d@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: "break break ;" etc. to break out of nested loops
Date: Sun, 7 Apr 2013 12:47:10 -0700 (PDT)
Lines: 196
Approved: news@gmane.org
Message-ID: <4f808b69-07f9-4bc6-8466-335f77c1989d@isocpp.org>
References: <1f964e4b-2762-43b8-85e5-41392926b07a@isocpp.org>
 <51614514.2060103@bubblescope.net>
 <f29c2b6c-af86-44e0-a813-bd4b2efc01a7@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_927_23670915.1365364030402"
X-Trace: ger.gmane.org 1365404018 24844 80.91.229.3 (8 Apr 2013 06:53:38 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 8 Apr 2013 06:53:38 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXLLRHD7IDRBP42Q6FQKGQE5B3GRPY@isocpp.org Mon Apr 08 08:53:39 2013
Return-path: <std-proposals+bncBCXLLRHD7IDRBP42Q6FQKGQE5B3GRPY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-gh0-f197.google.com ([209.85.160.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBP42Q6FQKGQE5B3GRPY@isocpp.org>)
	id 1UP5vj-0007Vd-RN
	for gclcip-std-proposals@m.gmane.org; Mon, 08 Apr 2013 08:51:52 +0200
Original-Received: by mail-gh0-f197.google.com with SMTP id r17sf7736583ghr.0
        for <gclcip-std-proposals@m.gmane.org>; Sun, 07 Apr 2013 23:51:50 -0700 (PDT)
X-Received: by 10.224.219.146 with SMTP id hu18mr4194132qab.3.1365364031518;
        Sun, 07 Apr 2013 12:47:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.27.137 with SMTP id t9ls2890859qeg.60.gmail; Sun, 07 Apr
 2013 12:47:10 -0700 (PDT)
X-Received: by 10.49.37.39 with SMTP id v7mr1451801qej.27.1365364030762;
        Sun, 07 Apr 2013 12:47:10 -0700 (PDT)
In-Reply-To: <f29c2b6c-af86-44e0-a813-bd4b2efc01a7@isocpp.org>
X-Original-Sender: vlad.moscow@mail.ru
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:3620
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/3620>

------=_Part_927_23670915.1365364030402
Content-Type: text/plain; charset=ISO-8859-1


On Sunday, April 7, 2013 10:40:04 PM UTC+4, Benjamin Lindley wrote:
>
> On Sunday, April 7, 2013 5:06:12 AM UTC-5, Chris Jefferson wrote:
>>
>>  On 05/04/13 20:23, temp...@freemail.hu wrote:
>>  
>> I hesitate to suggest this simple enhancement to the language, because 
>> it's so obvious that *somebody* must have thought of it before. In which 
>> case there must have been a good reason for rejecting it! But here goes: 
>>
>>  *Problem*
>> The *break* statement jumps out of the nearest enclosing *do, for, 
>> switch, *or *while *statement. All programmers know that breaking out of 
>> a nested for-loop to the *second*-nearest enclosing *do, for, switch, *
>> or *while *statement is a pain, and requires a *goto* statement or worse.
>>
>>  *Suggestion*
>> I suggest the following syntax:
>>
>>  The *break break* statement jumps out of the second-nearest enclosing *do, 
>> for, switch, *or *while *statement.
>>  The *break break* *break *statement jumps out of the third-nearest 
>> enclosing *do, for, switch, *or *while *statement.
>>  The *break break* *break break *statement jumps out of the 
>> fourth-nearest enclosing *do, for, switch, *or *while *statement.
>>  
>>  And so on. For instance:
>>
>>  for (int i = 0 ; i < 10 ; i++)
>>   for (int j = 0 ; j < 10 ; j++)
>>     for (int k = 0 ; k < 10 ; k++) {
>>        // do stuff
>>       if (a[i][j][k] == 0) break break break ; // the same as "goto 
>> ContinueExecution ;"
>>     }
>> ContinueExecution:
>>  
>>  Easy to understand. Easy to implement. 100% backwards compatible. 
>> What's not to like?
>>  
>>
>> Serious question: If this is equivalent to 'goto ContinueExecution', then 
>> why not just teach people to use goto? That has the advantage that I don't 
>> have to be careful to figure out where 'break break break;' will go, I can 
>> see the label!
>>
>> Chris
>>
>  
> It's only equivalent if the label ContinueExecution is actually there.  
> With the goto, you can't be sure where it's actually going to until you 
> actually find that label.  That could be up or down any distance within the 
> function.  With "break break;", you know exactly where to look. Down to the 
> end of the loop, and then down to the end of the next one.  Doesn't seem 
> that hard to me.
>
 
 
In my opinion break break is even worst then the goto statement. Using 
break break you should be very cautious counting loops and finding them. If 
due to refactoring some internal loop will be deleted break break passes 
the control in the invalid place. If I use the goto statement I will know 
at least where the control will be passed even if loops will be 
rearranged.:)
 
So I am against such a proposal. 

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_927_23670915.1365364030402
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>On Sunday, April 7, 2013 10:40:04 PM UTC+4, Benjamin Lindley wrote:<blo=
ckquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-=
color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid=
;" class=3D"gmail_quote">On Sunday, April 7, 2013 5:06:12 AM UTC-5, Chris J=
efferson wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left=
: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; borde=
r-left-style: solid;" class=3D"gmail_quote">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <div>On 05/04/13 20:23, <a>temp...@freemail.hu</a>
      wrote:<br>
    </div>
    <blockquote type=3D"cite">I hesitate to suggest this simple enhancement=
 to the
      language, because it's so obvious that <i>somebody</i> must have
      thought of it before. In which case there must have been a good
      reason for rejecting it! But here goes:
      <div>
        <div><br>
        </div>
        <div><i>Problem</i></div>
        <div>The <b>break</b>&nbsp;statement jumps out of the nearest
          enclosing <b>do, for, switch, </b>or <b>while </b>statement.
          All programmers know that breaking out of a nested for-loop to
          the <i>second</i>-nearest enclosing&nbsp;<b>do, for, switch,&nbsp=
;</b>or&nbsp;<b>while&nbsp;</b>statement
          is a pain, and requires a <b>goto</b>&nbsp;statement or worse.</d=
iv>
        <div><br>
        </div>
        <div><i>Suggestion</i></div>
        <div>I suggest the following syntax:</div>
        <div><br>
        </div>
        <div>The&nbsp;<b>break&nbsp;break</b> statement jumps out of the
          second-nearest enclosing&nbsp;<b>do, for, switch,&nbsp;</b>or&nbs=
p;<b>while&nbsp;</b>statement.<br>
        </div>
        <div>The&nbsp;<b>break&nbsp;break</b>&nbsp;<b>break&nbsp;</b>statem=
en<wbr>t jumps out of
          the third-nearest enclosing&nbsp;<b>do, for, switch,&nbsp;</b>or&=
nbsp;<b>while&nbsp;</b>statement.<br>
        </div>
        <div>The&nbsp;<b>break&nbsp;break</b>&nbsp;<b>break break&nbsp;</b>=
statement jumps
          out of the fourth-nearest enclosing&nbsp;<b>do, for, switch,&nbsp=
;</b>or&nbsp;<b>while&nbsp;</b>statement.<br>
        </div>
        <div><br>
        </div>
        <div>And so on. For instance:</div>
        <div><br>
        </div>
        <div>for (int i =3D 0 ; i &lt; 10 ; i++)</div>
        <div>&nbsp; for (int j =3D 0 ; j &lt; 10 ; j++)</div>
        <div>&nbsp; &nbsp; for (int k =3D 0 ; k &lt; 10 ; k++) {<br>
        </div>
        <div>&nbsp; &nbsp; &nbsp; // do stuff</div>
        <div>&nbsp; &nbsp; &nbsp; if (a[i][j][k] =3D=3D 0) break break brea=
k ; // the same
          as "goto ContinueExecution ;"</div>
        <div>&nbsp; &nbsp; }</div>
        <div>ContinueExecution:<br>
        </div>
        <div><br>
        </div>
        <div>Easy to understand. Easy to implement. 100% backwards
          compatible. What's not to like?</div>
      </div>
    </blockquote>
    <br>
    Serious question: If this is equivalent to 'goto ContinueExecution',
    then why not just teach people to use goto? That has the advantage
    that I don't have to be careful to figure out where 'break break
    break;' will go, I can see the label!<br>
    <br>
    Chris<br></div></blockquote><div>&nbsp;<br>It's only equivalent if the =
label ContinueExecution is actually there.&nbsp; With the goto, you can't b=
e sure where it's actually going to until you actually find that label.&nbs=
p; That could be up or down any distance within the function.&nbsp; With "b=
reak break;", you know exactly where to look. Down to the end of the loop, =
and then down to the end of the next one.&nbsp; Doesn't seem that hard to m=
e.<br></div></blockquote><div>&nbsp;</div><div>&nbsp;</div><div>In my&nbsp;=
opinion break break is even worst then the goto statement.&nbsp;Using break=
 break you should be very&nbsp;cautious&nbsp;counting loops and finding the=
m. If due to refactoring some internal loop will be deleted break break pas=
ses the control in the invalid place. If I&nbsp;use the&nbsp;goto statement=
 I will know at least where the control will be passed&nbsp;even if loops w=
ill be rearranged.:)</div><div>&nbsp;</div><div>So I am against such a prop=
osal.&nbsp;</div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_927_23670915.1365364030402--

.
