Topic: Concerns about N3587 "For Loop Exit Strategies
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 03:24:21 -0700 (PDT)
Raw View
------=_Part_62_450457.1366453461068
Content-Type: text/plain; charset=ISO-8859-1
The proposal N3587 does not provide better syntax. It looks at the follwing
"ugly" code:
something_t last; // Extra construction here.
for (auto& i : c)
{
if (some_condition(i))
{
last = i; // Extra copy here
goto EARLY; }
do_something(i);
}
do_stuff();
goto DONE;
EARLY:
do_something_else(last);
DONE:
and states that new syntax is needed. But the above loop can be easily
re-written using better forms:
(1)
bool ok = true;
for (auto& i : c)
{
if (some_condition(i))
{
ok = true;
do_something_else(i);
break;
}
do_something(i);
}
if (ok)
{
do_stuff();
}
(2)
for (auto& i : c)
{
if (some_condition(i))
{
do_something_else(i);
go EARLY;
}
do_something(i);
}
do_stuff();
EARLY:;
The proposal goes ahead and offers nee syntax:
if for (auto& i : c)
{
if (some_condition(i)) break;
do_something(i);
}
{
do_stuff(); // normal termination
}
else
{
do_something_else(i); // early exit
}
It does not look better than the above written two pieces of code.
Besides it may be confusing if the loop code uses more space:
the code for normal termination can be easily misinterpreted.
--
---
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_62_450457.1366453461068
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<p>The proposal N3587 does not provide better syntax. It looks at the follw=
ing "ugly" code:<br>something_t last; // Extra construction here.<br>for (a=
uto& i : c)<br>{<br>if (some_condition(i))<br>{<br>last =3D i; // Extra=
copy here<br>goto EARLY; }<br>do_something(i);<br>}<br>do_stuff();<br>goto=
DONE;<br>EARLY:<br>do_something_else(last);<br>DONE:</p><p>and states that=
new syntax is needed. But the above loop can be easily re-written using be=
tter forms:<br>(1)<br>bool ok =3D true;<br>for (auto& i : c)<br>{<br>&n=
bsp; if (some_condition(i))<br> {<br> &n=
bsp; ok =3D true;<br> =
do_something_else(i);<br> &=
nbsp; break;<br> }<br> do_somethi=
ng(i);<br>}<br>if (ok)<br>{<br> do_stuff();<br>}</p><p>(2=
)<br>for (auto& i : c)<br>{<br> if (some_condition(i)=
)<br> { <br>&nb=
sp; do_something_else(i);<br> &nbs=
p; go EARLY;<br> }<br> =
; do_something(i);<br>}<br>do_stuff();<br>EARLY:;</p><p>The pro=
posal goes ahead and offers nee syntax:<br>if for (auto& i : c)<br>{<br=
> if (some_condition(i)) break;<br> do_=
something(i);<br>}<br>{<br> do_stuff(); // normal termina=
tion<br>}<br>else<br>{<br> do_something_else(i); // early=
exit<br>}</p><p>It does not look better than the above written two pieces =
of code.<br>Besides it may be confusing if the loop code uses more space:<b=
r>the code for normal termination can be easily misinterpreted.<br></p>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
<br />
<br />
------=_Part_62_450457.1366453461068--
.
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 03:27:24 -0700 (PDT)
Raw View
------=_Part_479_32071295.1366453644629
Content-Type: text/plain; charset=ISO-8859-1
The proposal N3587 does not provide better syntax. It looks at the follwing
"ugly" code:
something_t last; // Extra construction here.
for (auto& i : c)
{
if (some_condition(i))
{
last = i; // Extra copy here
goto EARLY; }
do_something(i);
}
do_stuff();
goto DONE;
EARLY:
do_something_else(last);
DONE:
and states that new syntax is needed. But the above loop can be easily
re-written using better forms:
(1)
bool ok = true;
for (auto& i : c)
{
if (some_condition(i))
{
ok = false;
do_something_else(i);
break;
}
do_something(i);
}
if (ok)
{
do_stuff();
}
(2)
for (auto& i : c)
{
if (some_condition(i))
{
do_something_else(i);
go EARLY;
}
do_something(i);
}
do_stuff();
EARLY:;
The proposal goes ahead and offers nee syntax:
if for (auto& i : c)
{
if (some_condition(i)) break;
do_something(i);
}
{
do_stuff(); // normal termination
}
else
{
do_something_else(i); // early exit
}
It does not look better than the above written two pieces of code.
Besides it may be confusing if the loop code uses more space:
the code for normal termination can be easily misinterpreted.
--
---
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_479_32071295.1366453644629
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<p>The proposal N3587 does not provide better syntax. It looks at the follw=
ing "ugly" code:<br>something_t last; // Extra construction here.<br>for (a=
uto& i : c)<br>{<br>if (some_condition(i))<br>{<br>last =3D i; // Extra=
copy here<br>goto EARLY; }<br>do_something(i);<br>}<br>do_stuff();<br>goto=
DONE;<br>EARLY:<br>do_something_else(last);<br>DONE:</p><p>and states that=
new syntax is needed. But the above loop can be easily re-written using be=
tter forms:<br>(1)<br>bool ok =3D true;<br>for (auto& i : c)<br>{<br>&n=
bsp; if (some_condition(i))<br> {<br> &n=
bsp; ok =3D false;<br>  =
; do_something_else(i);<br> =
break;<br> }<br> do_someth=
ing(i);<br>}<br>if (ok)<br>{<br> do_stuff();<br>}</p><p>(=
2)<br>for (auto& i : c)<br>{<br> if (some_condition(i=
))<br> { <br>&n=
bsp; do_something_else(i);<br> &nb=
sp; go EARLY;<br> }<br>&nbs=
p; do_something(i);<br>}<br>do_stuff();<br>EARLY:;</p><p>The pr=
oposal goes ahead and offers nee syntax:<br>if for (auto& i : c)<br>{<b=
r> if (some_condition(i)) break;<br> do=
_something(i);<br>}<br>{<br> do_stuff(); // normal termin=
ation<br>}<br>else<br>{<br> do_something_else(i); // earl=
y exit<br>}</p><p>It does not look better than the above written two pieces=
of code.<br>Besides it may be confusing if the loop code uses more space:<=
br>the code for normal termination can be easily misinterpreted.<br></p>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
<br />
<br />
------=_Part_479_32071295.1366453644629--
.
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 03:30:06 -0700 (PDT)
Raw View
------=_Part_432_13807154.1366453806238
Content-Type: text/plain; charset=ISO-8859-1
The proposal N3587 does not provide better syntax. It looks at the
following "ugly" code:
something_t last; // Extra construction here.
for (auto& i : c)
{
if (some_condition(i))
{
last = i; // Extra copy here
goto EARLY;
}
do_something(i);
}
do_stuff();
goto DONE;
EARLY:
do_something_else(last);
DONE:
and states that new syntax is needed. But the above loop can be easily
re-written using better forms:
(1)
bool ok = true;
for (auto& i : c)
{
if (some_condition(i))
{
ok = false;
do_something_else(i);
break;
}
do_something(i);
}
if (ok)
{
do_stuff();
}
(2)
for (auto& i : c)
{
if (some_condition(i))
{
do_something_else(i);
go EARLY;
}
do_something(i);
}
do_stuff();
EARLY:;
The proposal goes ahead and offers new syntax:
if for (auto& i : c)
{
if (some_condition(i)) break;
do_something(i);
}
{
do_stuff(); // normal termination
}
else
{
do_something_else(i); // early exit
}
It does not look better than the above written two pieces of code.
Besides it may be confusing if the loop code uses more space:
the code for normal termination can be easily misinterpreted.
--
---
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_432_13807154.1366453806238
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>The proposal N3587 does not provide better syntax. It looks at the fol=
lowing "ugly" code:<br>something_t last; // Extra construction here.<br>for=
(auto& i : c)<br>{<br> if (some_condition(i))<br>&nb=
sp; {<br> =
last =3D i; // Extra copy here<br> &nbs=
p; goto EARLY; </div><div> }<br>&=
nbsp; do_something(i);<br>}<br>do_stuff();<br>goto DONE;<=
br>EARLY:<br>do_something_else(last);<br>DONE:</div><div> </div><p>and=
states that new syntax is needed. But the above loop can be easily re-writ=
ten using better forms:<br>(1)<br>bool ok =3D true;<br>for (auto& i : c=
)<br>{<br> if (some_condition(i))<br> {=
<br> ok =3D false;<br>  =
; do_something_else(i);<br> =
break;<br> }<br> &nbs=
p; do_something(i);<br>}<br>if (ok)<br>{<br> do_stuff();<=
br>}</p><p>(2)<br>for (auto& i : c)<br>{<br> if (some=
_condition(i))<br> { &=
nbsp; <br> do_something_else(i);<=
br> go EARLY;<br> &nbs=
p; }<br> do_something(i);<br>}<br>do_stuff();<br>EARLY:;<=
/p><p>The proposal goes ahead and offers new syntax:<br>if for (auto& i=
: c)<br>{<br> if (some_condition(i)) break;<br> &nb=
sp; do_something(i);<br>}<br>{<br> do_stuff(); // n=
ormal termination<br>}<br>else<br>{<br> do_something_else=
(i); // early exit<br>}</p><p>It does not look better than the above writte=
n two pieces of code.<br>Besides it may be confusing if the loop code uses =
more space:<br>the code for normal termination can be easily misinterpreted=
..</p><p><br> </p>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
<br />
<br />
------=_Part_432_13807154.1366453806238--
.
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 03:31:51 -0700 (PDT)
Raw View
------=_Part_459_10976649.1366453911335
Content-Type: text/plain; charset=ISO-8859-1
The proposal N3587 does not provide better syntax. It looks at the
following "ugly" code:
something_t last; // Extra construction here.
for (auto& i : c)
{
if (some_condition(i))
{
last = i; // Extra copy here
goto EARLY;
}
do_something(i);
}
do_stuff();
goto DONE;
EARLY:
do_something_else(last);
DONE:
and states that new syntax is needed. But the above loop can be easily
re-written using better forms:
(1)
bool ok = true;
for (auto& i : c)
{
if (some_condition(i))
{
ok = false;
do_something_else(i);
break;
}
do_something(i);
}
if (ok)
{
do_stuff();
}
(2)
for (auto& i : c)
{
if (some_condition(i))
{
do_something_else(i);
go EARLY;
}
do_something(i);
}
do_stuff();
EARLY:;
The proposal goes ahead and offers new syntax:
if for (auto& i : c)
{
if (some_condition(i)) break;
do_something(i);
}
{
do_stuff(); // normal termination
}
else
{
do_something_else(i); // early exit
}
It does not look better than the above written two pieces of code.
Besides it may be confusing if the loop code uses more space:
the code for normal termination can be easily misinterpreted.
--
---
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_459_10976649.1366453911335
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<p>The proposal N3587 does not provide better syntax. It looks at the follo=
wing "ugly" code:</p><p>something_t last; // Extra construction here.<br>fo=
r (auto& i : c)<br>{<br> if (some_condition(i))<br>&n=
bsp; {<br> last =3D i=
; // Extra copy here<br> goto EAR=
LY; <br> }<br> do_something(i);<br>}<br=
>do_stuff();<br>goto DONE;<br>EARLY:<br>do_something_else(last);<br>DONE:</=
p><p>and states that new syntax is needed. But the above loop can be easily=
re-written using better forms:<br>(1)<br>bool ok =3D true;<br>for (auto&am=
p; i : c)<br>{<br> if (some_condition(i))<br> =
{<br> ok =3D false;<br>&nb=
sp; do_something_else(i);<br> &nbs=
p; break;<br> }<br> &n=
bsp; do_something(i);<br>}<br>if (ok)<br>{<br> do_s=
tuff();<br>}</p><p>(2)<br>for (auto& i : c)<br>{<br> =
if (some_condition(i))<br> {  =
; <br> do_something_e=
lse(i);<br> go EARLY;<br> &n=
bsp; }<br> do_something(i);<br>}<br>do_stuff();<br>=
EARLY:;</p><p>The proposal goes ahead and offers new syntax:<br>if for (aut=
o& i : c)<br>{<br> if (some_condition(i)) break;<br>&=
nbsp; do_something(i);<br>}<br>{<br> do_stuff=
(); // normal termination<br>}<br>else<br>{<br> do_someth=
ing_else(i); // early exit<br>}</p><p>It does not look better than the abov=
e written two pieces of code.<br>Besides it may be confusing if the loop co=
de uses more space:<br>the code for normal termination can be easily misint=
erpreted.</p><p><br> </p>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
<br />
<br />
------=_Part_459_10976649.1366453911335--
.