Topic: proposal to introduce an extra, optional exit
Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Wed, 4 Mar 2015 12:14:12 -0800 (PST)
Raw View
------=_Part_6816_50386041.1425500052022
Content-Type: multipart/alternative;
boundary="----=_Part_6817_729634169.1425500052022"
------=_Part_6817_729634169.1425500052022
Content-Type: text/plain; charset=UTF-8
I would like to propose to introduce an extra optional condition in a loop
statement:
*for ( for-init-statement condition; expression; exit-condition) statement*
is equivalent to
*{ for-init-statement while ( condition ) { statement
if (exit-condition) break; expression ; }}*
That will make it easier to write loop using unsigned integral values:
*for (std::size_t i = N-1;; i--; i == 0)*
*{*
* ...*
*}*
*instead of writing loops like this:*
*for (std::size_t i = N; i-- != 0;)*
*{*
* ...*
*}*
*And it will be easier to deal with exit conditions before the loop counter
update.*
--
---
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/.
------=_Part_6817_729634169.1425500052022
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I would like to propose to introduce an extra optiona=
l condition in a loop statement:</div><div><br></div><div><font color=3D"#0=
000ff" face=3D"courier new,monospace"><strong>for ( for-init-statement cond=
ition; expression; exit-condition) statement</strong></font></div><div><br>=
</div><div>is equivalent to</div><div><br></div><div><font color=3D"#0000ff=
" face=3D"courier new,monospace"><strong>{<br> for-init-statement<br>=
while ( condition ) {<br> &=
nbsp; statement<br> &nb=
sp; if (exit-condition)<br> =
break;<br> &nbs=
p; expression ;<br> &n=
bsp; }<br>}</strong></font></div><div><br></d=
iv><div><br></div><div>That will make it easier to write loop using unsigne=
d integral values:</div><div><font face=3D"courier new,monospace"><strong>f=
or (std::size_t i =3D N-1;; i--; i =3D=3D 0)</strong></font></div><div><fon=
t face=3D"courier new,monospace"><strong>{</strong></font></div><div><font =
face=3D"courier new,monospace"><strong> ...</strong></font></di=
v><div><font face=3D"courier new,monospace"><strong>}</strong></font></div>=
<div><strong><font face=3D"Courier New"><br></font></strong></div><div><str=
ong><font face=3D"Courier New">instead of writing loops like this:</font></=
strong></div><div><font face=3D"Courier New"><div><font face=3D"courier new=
,monospace"><strong>for (std::size_t i =3D N; i-- !=3D 0;)</strong></font><=
/div><div><font face=3D"courier new,monospace"><strong>{</strong></font></d=
iv><div><font face=3D"courier new,monospace"><strong> ...</stro=
ng></font></div><div><font face=3D"courier new,monospace"><strong>}</strong=
></font></div><div><strong><br></strong></div><div><strong>And it will be e=
asier to deal with exit conditions before the loop counter update.</strong>=
</div></font></div></div>
<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 <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_6817_729634169.1425500052022--
------=_Part_6816_50386041.1425500052022--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Wed, 4 Mar 2015 20:21:45 +0000
Raw View
The official position is that we need new control structures like a
hole in the head. Good luck!
On 3/4/15, Mikhail Semenov <mikhailsemenov1957@gmail.com> wrote:
> I would like to propose to introduce an extra optional condition in a loop
> statement:
>
> *for ( for-init-statement condition; expression; exit-condition) statement*
>
> is equivalent to
>
>
>
>
>
>
>
>
>
> *{ for-init-statement while ( condition ) { statement
>
> if (exit-condition) break; expression ; }}*
>
>
> That will make it easier to write loop using unsigned integral values:
> *for (std::size_t i = N-1;; i--; i == 0)*
> *{*
> * ...*
> *}*
>
> *instead of writing loops like this:*
> *for (std::size_t i = N; i-- != 0;)*
> *{*
> * ...*
> *}*
>
> *And it will be easier to deal with exit conditions before the loop counter
>
> update.*
>
> --
>
> ---
> 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/.
>
--
---
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/.
.
Author: Pavel Kretov <firegurafiku@gmail.com>
Date: Thu, 05 Mar 2015 20:03:51 +0300
Raw View
> The official position is that we need new control structures like a
> hole in the head. Good luck!
Especially true for an ad hoc kludge for "for" loop. But may be some
better ideas have a chance? For example, I'd wish to see a pattern
matching like construct in C++ some day.
=E2=80=94=E2=80=94=E2=80=94 Pavel Kretov.
--=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/.
.