220 29836 <572a5592-ec0f-47f2-8253-aedb23ae29ce@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: alexandre.isoard@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Looping construct with in-the-middle test: do { ... }
 while(...) { ... }
Date: Fri, 16 Dec 2016 06:49:47 -0800 (PST)
Lines: 366
Approved: news@gmane.org
Message-ID: <572a5592-ec0f-47f2-8253-aedb23ae29ce@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_501_553955834.1481899787455"
X-Trace: blaine.gmane.org 1481899794 1112 195.159.176.226 (16 Dec 2016 14:49:54 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Dec 2016 14:49:54 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDXMXE5S7EMRBDH6Z7BAKGQEGOPVNVY@isocpp.org Fri Dec 16 15:49:50 2016
Return-path: <std-proposals+bncBDXMXE5S7EMRBDH6Z7BAKGQEGOPVNVY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f197.google.com ([209.85.213.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDXMXE5S7EMRBDH6Z7BAKGQEGOPVNVY@isocpp.org>)
	id 1cHtpQ-0007ME-F2
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Dec 2016 15:49:44 +0100
Original-Received: by mail-yb0-f197.google.com with SMTP id h184sf107843699ybb.7
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Dec 2016 06:49:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=ubvxV4TZaDYv+NfBjJCMBfbENa7r5vhbwDDx/wtOmG4=;
        b=mU5orLnem5UgLtdt3AxCFVgLXabF+3GAqS4wKo4QUjPbTBK1YvoLBleP8yJ5s9IcyB
         4//04JVdP1hAJ5Huyvlq5opXjg04nVvV3fAjXoZwHuJVQDL04d0XiCfHbv2oKLqN4X5A
         g8S73e/f/ujB5kH2aD36PmMpcpZyKiACwjt5d2C1vTN5Ul5A/VboKmutkYFkS9470RW4
         Wo7jNjmesHjvGaOIv7OdCJ746J+3xdb9AAEW6DLnz7Cd2ItOzGw9EsuT/qrR7qcYrgW8
         nnXueRTpNK/exZgmUG5MJEJLIxfi/Egl68i5CbPOp9c80CSkShmm0fsR2TO40qgTJqei
         BH6w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=ubvxV4TZaDYv+NfBjJCMBfbENa7r5vhbwDDx/wtOmG4=;
        b=n7Ol1Vt8aCPTqC6ReFBmvvxk8oBPG1hyXHC1wM730dPcGBfGqUTcYe0OWdeS1jJixD
         L3ZoSyh8O05+SqXdXXUeU13BxuW0JRNhhAQtvBBTShPNwe8ijGZTWqlV73kPn/rzVJOQ
         ynKt3mI6JEghapCSPSVr44SaF6jjBqPNruna5B9fsEekZQOGMe+syhV0UODry86/6u2w
         QjC39J0R+K1I1KcCcjgTrjLiDvNpuQ3qQn+WOQFcjI5VDYvU1xRE5cdOor4//wMXb6e2
         V/x9cj6slvgu8QKoHvHUGQ00mtlK70JbF8Fo7W+MZDJGK+YbBIXzBUSz3aqZxzHA75jz
         U79Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=ubvxV4TZaDYv+NfBjJCMBfbENa7r5vhbwDDx/wtOmG4=;
        b=aVT2VznJrZwkRyZiRqBwts+hZr5Tz4zDB3u+jyIDlUyiFEwdZLij+/ChRCO0opwPqs
         HxbqdhTcUZq9bDTJx0Nvb8qC2gwmOci2lKoBDSw6sFX+oZbVaEM4m+gwLSa7vLsLSPAh
         8rnmRj10r0VW96u6Gy24sHwvr7CSN2YuHtz8P6dqJWHcR1QxHAkfwohyT9lVoO0U9RH3
         WUANhf9Bn5YxDhmCBGMgzKuVf6Ssomql2f7wNquSAC+Qu5+FwyvuYV7LmsQGg8SBLyP+
         uK24rPS07UwtpQ3aU/vOtW6GGzxIMlfqD37kWL8MnWaYi6oKNkCgekzXhnMmdsHSfbch
         LMOw==
X-Gm-Message-State: AIkVDXJyhfDXGRyoRQtYNHWz09MiwBcY12JX5aPg/0xUJyCRgxHkQkTA4uPkXdXUZUuKVw==
X-Received: by 10.129.26.213 with SMTP id a204mr853252ywa.111.1481899788652;
        Fri, 16 Dec 2016 06:49:48 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.1.164 with SMTP id e33ls8391281ote.43.gmail; Fri, 16 Dec
 2016 06:49:47 -0800 (PST)
X-Received: by 10.157.18.211 with SMTP id g77mr150252otg.14.1481899787834;
        Fri, 16 Dec 2016 06:49:47 -0800 (PST)
X-Original-Sender: alexandre.isoard@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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:29836
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29836>

------=_Part_501_553955834.1481899787455
Content-Type: multipart/alternative; 
	boundary="----=_Part_502_973598154.1481899787456"

------=_Part_502_973598154.1481899787456
Content-Type: text/plain; charset=UTF-8

C++ provides two kind of while loop structures:

while loop with at-beginning test:
bool condition = test();
while (condition) {
  action();
  condition = test();
}
Useful when we want to perform the content of the loop as long as the test 
is true and we don't want to perform the content if the test is false at 
the beginning.

while loop with at-end test:
do {
  action();
  bool condition = test();
} while (condition);
Useful when we want to perform the content of the loop as long as the test 
is true but we still want to perform the content of the loop at least once 
even when the test is false at the beginning.
Frequent when looking for fixpoint in an algorithm. We perform one 
iteration, see if it is sufficient, else continue.

I propose an additional while loop structures that fit the syntax of the 
second form:
do {
  bool condition = test();
} while (condition) {
  action();
}
The semantic is as follow:

   1. The do part is always executed when enter the loop (even if the test 
   would be false)
   2. We interpret the condition
   3. If the test is false, we exit the loop structure (and therefore skip 
   the while part)
   4. If the test is true, we execute the while part *and *the do part and 
   go back to point 2

As you may see, this third form is a generalization of the second form. We 
simply allow the mandatory ';' to be replaced with code.
You may also remark that the third form has exactly the same behavior as 
the first form, except that the condition variable has a live-range 
restricted to the loop structure.

An other use case:
std::ostream &join(std::ostream &os, iterator it, iterator end, const std::
string &sep) {
  if (it != end) {
    os << *it;
    while(it != end) {
      os << sep;
      os << *it;
    }
  }
  return os;
}

Could be written:
std::ostream &join(std::ostream &os, iterator it, iterator end, const std::
string &sep) {
  if (it != end)
    do {
      os << *it;
    } while(it != end) {
      os << sep;
    }
  return os;
}

There are many weird stuff with such a construct:

   - Potential syntax problems with LALR parsers.
   - We may want live-ranges of the variables declared in the do section to 
   extend to the condition and the while section.
   - We may not want the live-ranges of the variables declared in the while 
   section to extend to the do section and the condition.

What do you think?

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/572a5592-ec0f-47f2-8253-aedb23ae29ce%40isocpp.org.

------=_Part_502_973598154.1481899787456
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>C++ provides two kind of while loop structures:</div>=
<div><br></div><div>while loop with at-beginning test:</div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><font=
 color=3D"#660066"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> con=
dition </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> test</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">while</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">condition</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">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0 action</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0 condition </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> test</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></font></=
div></code></div><div>Useful when we want to perform the content of the loo=
p as long as the test is true and we don&#39;t want to perform the content =
if the test is false at the beginning.</div><div><br></div>while loop with =
at-end test:</div><div><div class=3D"prettyprint" style=3D"background-color=
: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid=
; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><font color=3D"#000000"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">do</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 action</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> condition </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> t=
est</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">while</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">condition</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">);</span></font></div></code></div><div>Useful when we want t=
o perform the content of the loop as long as the test is true but we still =
want to perform the content of the loop at least once even when the test is=
 false at the beginning.</div><div>Frequent when looking for fixpoint in an=
 algorithm. We perform one iteration, see if it is sufficient, else continu=
e.</div><br>I propose an additional while loop structures that fit the synt=
ax of the second form:</div><div><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">do</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">boo=
l</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> conditio=
n </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> test</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">while</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>condition</span><span style=3D"color: #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">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 action</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">}</span></div></code></div>The se=
mantic is as follow:</div><div><ol><li>The <font face=3D"courier new, monos=
pace">do </font>part is always executed when enter the loop (even if the te=
st would be false)</li><li>We interpret the condition</li><li>If the test i=
s <font face=3D"courier new, monospace">false</font>, we <font face=3D"aria=
l, sans-serif">exit </font>the loop structure (and therefore skip the <font=
 face=3D"courier new, monospace">while </font>part)</li><li>If the test is =
<font face=3D"courier new, monospace">true</font>, we execute the <font fac=
e=3D"courier new, monospace">while </font>part <b>and </b>the <font face=3D=
"courier new, monospace">do </font>part and go back to point 2</li></ol>As =
you may see, this third form is a generalization of the second form. We sim=
ply allow the mandatory &#39;;&#39; to be replaced with code.</div><div>You=
 may also remark that the third form has exactly the same behavior as the f=
irst form, except that the <font face=3D"courier new, monospace">condition =
</font>variable has a live-range restricted to the loop structure.</div><di=
v><br></div>An other use case:<div class=3D"prettyprint" style=3D"backgroun=
d-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style=
: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypr=
int"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">ostream </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">join=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">ostream </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">os</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> iterator it</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> iterator </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">end</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">string</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">sep</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">it </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">!=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">end</span><span style=3D"color: #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">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 os </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt=
;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">it</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">while</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">it </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">!=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">end</span><span style=3D"color: #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">{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
os </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
font color=3D"#008800"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">sep</span></font><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0 =C2=A0 =C2=A0 os </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">it</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> os</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">}</span></div></code></div><div><br></div><div>Could b=
e written:</div><div><div class=3D"prettyprint" style=3D"background-color: =
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; =
border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ostrea=
m </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">join</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">ostream </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">os</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> iterator it</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> iterator </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">sep</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">it </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">!=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">end</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>do</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
os </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">it</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">while</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">it </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
!=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span=
 style=3D"color: #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">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 os </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><font color=3D"#008800"><=
span style=3D"color: #000;" class=3D"styled-by-prettify">sep</span></font><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> os</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span></div></code></div><br>There are many weird stuff=
 with such a construct:</div><div><ul><li>Potential syntax problems with LA=
LR parsers.</li><li>We may want live-ranges of the variables declared in th=
e do section to extend to the condition and the while section.</li><li>We m=
ay not want the live-ranges of the variables declared in the while section =
to extend to the do section and the condition.</li></ul><div>What do you th=
ink?</div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/572a5592-ec0f-47f2-8253-aedb23ae29ce%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/572a5592-ec0f-47f2-8253-aedb23ae29ce=
%40isocpp.org</a>.<br />

------=_Part_502_973598154.1481899787456--

------=_Part_501_553955834.1481899787455--

.
