220 12252 <35c8da4b-fb3e-4d79-8344-e414b6872554@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Douglas Boffey <douglas.boffey@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Fwd: Study on usage of break label / continue label
Date: Wed, 13 Aug 2014 00:40:53 -0700 (PDT)
Lines: 294
Approved: news@gmane.org
Message-ID: <35c8da4b-fb3e-4d79-8344-e414b6872554@isocpp.org>
References: <CAB+4KHKZHy2iPRKKaFunX_QzzKC50zwu_ui8hX=ekaKQMxZEdQ@mail.gmail.com>	<CAB+4KHKBQgVpHrzvgGRWOTcTPTc1O6a4wmHa4jbDME1iJ-WSeQ@mail.gmail.com>	<CAGsORuCngd3hw6nOsaLGMdQ9AvCOd11Qh4jD62CjQBWu1jHJ+A@mail.gmail.com>	<f54192f8-99ce-4915-897d-cf5315237d80@isocpp.org>
 <CAGsORuDwvauJWV0ps6cgD3hru5WpqwcO_EmJ+g+WGZXt+N++Jg@mail.gmail.com>
 <25d71a9d-2112-4b70-9103-af95731ed766@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2925_1600440311.1407915653301"
X-Trace: ger.gmane.org 1407915661 29833 80.91.229.3 (13 Aug 2014 07:41:01 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 13 Aug 2014 07:41:01 +0000 (UTC)
Cc: inkwizytoryankes@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDSIZVXVVUFBBBNNVSPQKGQETIJ6WNI@isocpp.org Wed Aug 13 09:40:56 2014
Return-path: <std-proposals+bncBDSIZVXVVUFBBBNNVSPQKGQETIJ6WNI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f72.google.com ([209.85.219.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDSIZVXVVUFBBBNNVSPQKGQETIJ6WNI@isocpp.org>)
	id 1XHTB1-0001x0-CC
	for gclcip-std-proposals@m.gmane.org; Wed, 13 Aug 2014 09:40:55 +0200
Original-Received: by mail-oa0-f72.google.com with SMTP id m1sf51595919oag.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 13 Aug 2014 00:40:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=3ovS3KnQ7chO2ro92H+bz1ffDaI5Tc0tGrcxl00lMJY=;
        b=uqUxq1E6P/5M9wdq7e4OwqgO2njO9c0Xn+z2PWDoqFPz4IJ3UF+e3+lxqASGloL84s
         +Bz9JL3+poSiaW2PHm0CCQKsapOeqPFc0H39dui0p0bbDSdCM+VPylNEBqdP83OkrC4n
         D+rrWuz01wokS+GnuuSaKXQ6EerNed/UBDXmo+h+FgUPYbKA2jpP5wPCssRqKEL7MMIG
         VDs4VQnG5WJsajMZcEun5X7kjy3kIKho5frsZqTzYH3GzUlNk7NfMrohHYhXaAt+WMsH
         /1Jb4zqu5PIHtySqIrc+4zzmB9jE2UQhwke0PVHq7rfn7UkO5cGdjEbUM7pZoeui2XtM
         1aag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=3ovS3KnQ7chO2ro92H+bz1ffDaI5Tc0tGrcxl00lMJY=;
        b=d9ZWEeJ1GjN0AyBlBqzDJgxhrC7xLSmnyw8L7oPxQ1WW5XNtX+04Vvx7Z0v7nwlIIM
         8C7DVnj5D9cNWdQ/y0qpULTXnLefCBScAkWJbb/lRoI8S+Y/14OSJ+O/iDwjwHkWHji9
         yYvwOhhJL0ROfhw5nFHMHwGw34wE3ypu1NnSiVqR9Zh4As4Amoy/cM5L48o5JvuQH8Sj
         DhBiY2MkxnjMNH7UV9eQChMxMBD4ETRZ6IP1cf+lRfLz9Zkx4Te+Rulr960Jx2Cs9i+N
         x7XKF0QrN9nRmThLL1WGbwpryw+DoH8g1pHFdyXcxy6ZX4IRn18wxFYxdzeiNxWWZG/P
         ydxQ==
X-Gm-Message-State: ALoCoQln+W2qu1KC/dMFkd7Uvyu6+e5vAZCDg6UzeJIzUzZy3P6gSMBCfS2qjspLCItO7TUylsfe
X-Received: by 10.42.26.12 with SMTP id d12mr1380514icc.24.1407915654435;
        Wed, 13 Aug 2014 00:40:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.41.211 with SMTP id z77ls483451qgz.54.gmail; Wed, 13 Aug
 2014 00:40:53 -0700 (PDT)
X-Received: by 10.140.20.151 with SMTP id 23mr16435qgj.13.1407915653658;
        Wed, 13 Aug 2014 00:40:53 -0700 (PDT)
In-Reply-To: <25d71a9d-2112-4b70-9103-af95731ed766@isocpp.org>
X-Original-Sender: Douglas.Boffey@gmail.com
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>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:12252
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/12252>

------=_Part_2925_1600440311.1407915653301
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Friday, 8 August 2014 18:19:33 UTC+1, inkwizyt...@gmail.com wrote:
>
> Some time ago was proposition to allow "chain" breaks.
> Something like that:
> for(...)
> {
>     while(...)
>     {
>         if(...)
>             break break; //break while and for
>         else if(...)
>             break continue; //break while but continue for
>     }
> }
> But I think that label version is better. Mainly because is more secure=
=20
> when you add or remove nested loops.
> Label break could detect situation when you move big block of code to=20
> outside of loop its belongs.
> Chained breaks will accept new position as long nested level is deep=20
> enough even if new context is completely different.
>
> Hmm, so you need to count the number of breaks and continues, and match=
=20
them to the nesting level?  Does that help produce more legible code?

I would prefer some sort of named control statements, e.g.

for [foo] (=E2=80=A6) {
  // =E2=80=A6
  while [bar] (=E2=80=A6) {
    // =E2=80=A6
    if (baz)
      break foo;
      // =E2=80=A6
  }
  // =E2=80=A6
} =20

>
> On Friday, August 8, 2014 3:20:55 AM UTC+2, Zhihao Yuan wrote:
>>
>> On Thu, Aug 7, 2014 at 8:03 PM, <gmis...@gmail.com> wrote:
>>
>>>
>>>   case ...:
>>>>     break loop:
>>>>     ...
>>>>     continue loop:  // `loop` is a contextual keyword
>>>>
>>>
>>> That's a simple creative idea I hadn't thought of but no doubt the rest=
=20
>>> of the world did.
>>>
>>
>> If you read those code, you are going to immediate have this
>> idea.  Because in the code, I keep seeing
>>
>>   loop: for/while
>>   ... =20
>>     switch (...) {
>>     ...
>>       break loop;  // and even `continue loop;`
>>
>> And I feel "What's a pattern!", but later, in (B), I see
>>
>>   lab07: ...
>>     switch ...
>>       break lab07;
>>   ...
>>   lab08: ...
>>       break lab08;
>>
>> Then I realized that the pattern above doesn't always work,
>> because unlike variable names, label names are not scoped,
>> so that you can't have two `loop` in one function.
>>
>> Then I say "OK, let's forget about the label name..." :)
>>
>> Can C be broken down more, does your analysis invite "break switch" for=
=20
>>> when you are in a  loop in a case statement and want out?
>>>
>>>
>> I did not see a use complex like that, but one of the two
>> undetermined samples might be the case.
>>
>> However, it's a interesting question that a`break loop`
>> inside a loop inside a `switch` inside a loop should break
>> which loop.  I think it should still break the outer one.  That is:
>>
>>   for (...) {  // loop1
>>     switch (...) {
>>     case ...:
>>       while (...) {  // loop2
>>         break;    // get out of loop2, continue switching
>>         break loop;    // get out of loop1
>>       }
>>     }
>>   }
>>
>> --=20
>> Zhihao Yuan, ID lichray
>> The best way to predict the future is to invent it.
>> ___________________________________________________
>> 4BSD -- http://bit.ly/blog4bsd=20
>>
>

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_2925_1600440311.1407915653301
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, 8 August 2014 18:19:33 UTC+1, inkwizyt.=
...@gmail.com  wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Some time ago was proposition to allow "chain" breaks.<br>Somethin=
g like that:<br><div style=3D"background-color:rgb(250,250,250);border-colo=
r:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word=
"><code><div><span style=3D"color:#008">for</span><span style=3D"color:#660=
">(...)</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=
=3D"color:#008">while</span><span style=3D"color:#660">(...)</span><span st=
yle=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span=
 style=3D"color:#008">if</span><span style=3D"color:#660">(...)</span><span=
 style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>=
<span style=3D"color:#008">break</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">break</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#800">//break while a=
nd for</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </s=
pan><span style=3D"color:#008">else</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#008">if</span><span style=3D"color:#660">(...)</spa=
n><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
</span><span style=3D"color:#008">break</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">continue</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//bre=
ak while but continue for</span><span style=3D"color:#000"><br>&nbsp; &nbsp=
; </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=
</span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br></=
span></div></code></div>But I think that label version is better. Mainly be=
cause is more secure when you add or remove nested loops.<br>Label break co=
uld detect situation when you move big block of code to outside of loop its=
 belongs.<br>Chained breaks will accept new position as long nested level i=
s deep enough even if new context is completely different.<br><br></div></b=
lockquote><div>Hmm, so you need to count the number of breaks and continues=
, and match them to the nesting level?&nbsp; Does that help produce more le=
gible code?<br><br>I would prefer some sort of named control statements, e.=
g.<br><br></div><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">foo</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(=E2=80=A6)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; =
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =E2=80=
=A6</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">while<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">bar</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(=E2=80=A6)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// =E2=80=A6</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b=
az</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;=
 &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">br=
eak</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbs=
p; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =E2=
=80=A6</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
&nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =E2=80=
=A6</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">&nbsp; </span><br></di=
v></code></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
"><br>On Friday, August 8, 2014 3:20:55 AM UTC+2, Zhihao Yuan wrote:<blockq=
uote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Thu, Aug 7, 2014 at 8:=
03 PM,  <span dir=3D"ltr">&lt;<a>gmis...@gmail.com</a>&gt;</span> wrote:<br=
><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><br><div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);bord=
er-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><div>&nbsp; cas=
e ...:<br>
</div><div>&nbsp;&nbsp;&nbsp; break loop:<br>&nbsp;&nbsp;&nbsp; ...<br></di=
v><div>
&nbsp;&nbsp;&nbsp; continue loop:&nbsp; // `loop` is a contextual keyword<b=
r></div></div></blockquote><div><br></div></div><div>That's a simple creati=
ve idea I hadn't thought of but no doubt the rest of the world did.</div></=
div></blockquote>
<div><br></div><div>If you read those code, you are going to immediate have=
 this<br></div><div>idea.&nbsp; Because in the code, I keep seeing<br><br><=
/div><div>&nbsp; loop: for/while<br>&nbsp; ...&nbsp; <br></div><div>&nbsp;&=
nbsp;&nbsp; switch (...) {<br>&nbsp;&nbsp;&nbsp; ...<br>
</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break loop;&nbsp; // and even `co=
ntinue loop;`<br><br></div><div>And I feel "What's a pattern!", but later, =
in (B), I see<br><br></div><div>&nbsp; lab07: ...<br></div><div>&nbsp;&nbsp=
;&nbsp; switch ...<br></div><div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break lab07;<br>&nbsp; ...<br></div><div>&nb=
sp; lab08: ...<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break lab08;<br=
><br></div><div>Then I realized that the pattern above doesn't always work,=
<br></div><div>because unlike variable names, label names are not scoped,<b=
r>
</div><div>so that you can't have two `loop` in one function.<br><br></div>=
<div>Then I say "OK, let's forget about the label name..." :)<br></div><div=
> <br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Can C be broken down more,&nbsp;does your analysis&nbsp;in=
vite&nbsp;"break switch"&nbsp;for when you are in a &nbsp;loop in a case st=
atement and&nbsp;want out?</div><div><div>



<br>
</div></div></blockquote></div><br></div><div>I did not see a use complex l=
ike that, but one of the two<br></div><div>undetermined samples might be th=
e case.<br><br></div><div>
However, it's a interesting question that a`break loop`<br>inside a loop in=
side a `switch` inside a loop should break<br>which loop.&nbsp; I think it =
should still break the outer one.&nbsp; That is:<br><br></div><div>
&nbsp; for (...) {&nbsp; // loop1<br></div><div>&nbsp;&nbsp;&nbsp; switch (=
....) {<br></div><div>&nbsp;&nbsp;&nbsp; case ...:<br></div><div>&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp; while (...) {&nbsp; // loop2<br></div><div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;&nbsp;&nbsp;&nbsp; // get =
out of loop2, continue switching<br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; break loop;&nbsp;&nbsp;&nbsp; // get out of loop1<br>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br clear=3D"a=
ll"></div><div><br>-- <br>Zhihao Yuan, ID lichray<br>
The best way to predict the future is to invent it.<br>____________________=
__________<wbr>_____________________<br>4BSD -- <a href=3D"http://bit.ly/bl=
og4bsd" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com=
/url?q\75http%3A%2F%2Fbit.ly%2Fblog4bsd\46sa\75D\46sntz\0751\46usg\75AFQjCN=
ENWZA3DF1H_gEgIkwnCr7FAkiCyQ';return true;" onclick=3D"this.href=3D'http://=
www.google.com/url?q\75http%3A%2F%2Fbit.ly%2Fblog4bsd\46sa\75D\46sntz\0751\=
46usg\75AFQjCNENWZA3DF1H_gEgIkwnCr7FAkiCyQ';return true;">http://bit.ly/blo=
g4bsd</a>
</div></div>
</blockquote></div></blockquote></div>

<p></p>

-- <br />
<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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2925_1600440311.1407915653301--

.
