220 3597 <2055e281-08bf-4b00-aeef-22494c9a6c08@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: temptony@freemail.hu
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: "break break ;" etc. to break out of nested loops
Date: Fri, 5 Apr 2013 13:16:41 -0700 (PDT)
Lines: 126
Approved: news@gmane.org
Message-ID: <2055e281-08bf-4b00-aeef-22494c9a6c08@isocpp.org>
References: <1f964e4b-2762-43b8-85e5-41392926b07a@isocpp.org>
 <85c0ae97-3440-4a81-96c2-1af7ebb892ba@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2294_8534313.1365193001161"
X-Trace: ger.gmane.org 1365274100 8141 80.91.229.3 (6 Apr 2013 18:48:20 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 6 Apr 2013 18:48:20 +0000 (UTC)
Cc: temptony@freemail.hu
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCF55ZN354IBBKXC7SFAKGQELYY7RLY@isocpp.org Sat Apr 06 20:48:20 2013
Return-path: <std-proposals+bncBCF55ZN354IBBKXC7SFAKGQELYY7RLY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f69.google.com ([209.85.219.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCF55ZN354IBBKXC7SFAKGQELYY7RLY@isocpp.org>)
	id 1UOXGV-0007ti-0F
	for gclcip-std-proposals@m.gmane.org; Sat, 06 Apr 2013 19:50:59 +0200
Original-Received: by mail-oa0-f69.google.com with SMTP id k14sf28118122oag.8
        for <gclcip-std-proposals@m.gmane.org>; Sat, 06 Apr 2013 10:50:58 -0700 (PDT)
X-Received: by 10.182.113.69 with SMTP id iw5mr3342427obb.33.1365193002732;
        Fri, 05 Apr 2013 13:16:42 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.132.193 with SMTP id ow1ls494077obb.58.gmail; Fri, 05 Apr
 2013 13:16:41 -0700 (PDT)
X-Received: by 10.182.153.194 with SMTP id vi2mr306227obb.37.1365193001917;
        Fri, 05 Apr 2013 13:16:41 -0700 (PDT)
In-Reply-To: <85c0ae97-3440-4a81-96c2-1af7ebb892ba@isocpp.org>
X-Original-Sender: temptony@freemail.hu
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:3597
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/3597>

------=_Part_2294_8534313.1365193001161
Content-Type: text/plain; charset=ISO-8859-1

It's not the business of the C++ standard to push programmers towards 
keeping their functions simple! Nothing you say speaks against allowing *break 
break...* into the language.

On Friday, April 5, 2013 9:53:33 PM UTC+2, Andrew Sandoval wrote:
>
> On Friday, April 5, 2013 2:23:33 PM UTC-5, 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?
>>
>
> How about *return*?  That way you are pushed towards keeping your 
> functions simple.
> Not trying to be negative, but that seems like something you wouldn't hit 
> too often in C++ code -- C, yes, but hopefully not C++.
>
> -Andrew Sandoval
>  
>

-- 

--- 
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_2294_8534313.1365193001161
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

It's not the business of the C++ standard to push programmers towards keepi=
ng their functions simple! Nothing you say speaks against allowing <b>break=
 break...</b>&nbsp;into the language.<br><br>On Friday, April 5, 2013 9:53:=
33 PM UTC+2, Andrew Sandoval wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">On Friday, April 5, 2013 2:23:33 PM UTC-5, <a>temp...@freemail.hu</a>=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8e=
x;border-left:1px #ccc solid;padding-left:1ex">I hesitate to suggest this s=
imple 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 g=
ood reason for rejecting it! But here goes:<div><div><br></div><div><i>Prob=
lem</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 programmer=
s 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>state=
ment is a pain, and requires a <b>goto</b>&nbsp;statement or worse.</div><d=
iv><br></div><div><i>Suggestion</i></div><div>I suggest the following synta=
x:</div><div><br></div><div>The&nbsp;<b>break&nbsp;break</b> statement jump=
s out of the second-nearest enclosing&nbsp;<b>do, for, switch,&nbsp;</b>or&=
nbsp;<b>while&nbsp;</b>statement.<br></div><div>The&nbsp;<b>break&nbsp;brea=
k</b>&nbsp;<b>break&nbsp;</b>statemen<wbr>t jumps out of the third-nearest =
enclosing&nbsp;<b>do, for, switch,&nbsp;</b>or&nbsp;<b>while&nbsp;</b>state=
ment.<br></div><div>The&nbsp;<b>break&nbsp;break</b>&nbsp;<b>break break&nb=
sp;</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++)</d=
iv><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 break ; // 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><div><br>How about <span style=
=3D"color:rgb(0,0,255)"><b><span style=3D"font-family:courier new,monospace=
">return</span></b></span>?&nbsp; That way you are pushed towards keeping y=
our functions simple.<br>Not trying to be negative, but that seems like som=
ething you wouldn't hit too often in C++ code -- C, yes, but hopefully not =
C++.<br><br>-Andrew Sandoval<br>&nbsp;<br></div></blockquote>

<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_2294_8534313.1365193001161--

.
