Topic: Allowing unnammed loop variable in range-based


Author: "T. C." <rs2740@gmail.com>
Date: Fri, 3 Jun 2016 15:54:10 -0700 (PDT)
Raw View
------=_Part_2947_1027923243.1464994450681
Content-Type: multipart/alternative;
 boundary="----=_Part_2948_492500116.1464994450681"

------=_Part_2948_492500116.1464994450681
Content-Type: text/plain; charset=UTF-8



On Friday, June 3, 2016 at 6:37:16 AM UTC-4, schreiber...@gmail.com wrote:
>
> I have defined a utility function "range(n)" that generates a input
> sequence of integers from 0 to n-1 such that
> for (int i : range(10)) {
>     // ...
> }
>
> // Is equivalent to
>
> for (int i = 0; i < 10; ++i) {
>     // ...
> }
>
> I think a similar utility is present in the range TS, although I do not
> know it exact name.
>
> I recently encountered a situation when I needed to perform "n"
> iterations, but without caring about "which" iteration is currently being
> performed; I didn't use the value of "i" in the example above. The problem
> is, compilers start warning on unused variable... See running code here:
> http://cpp.sh/9lot
>
> Obviously there are various ways around this, in particular using the
> traditional for loop does not generate a warning. But range-based for loops
> are superior in many ways, and it would be good to be able to use it in
> this situation. I also think the warning is correct, since there is no way
> for the compiler to know your intention here (maybe you just made a typo
> and intended to use "i"?). Therefore, do you think it would be possible to
> solve this issue by allowing the range variable to be unnamed? Something
> like:
>
> for (int : range(10)) {
>     // ...
> }
>
> That would also make one's intention clearer.
>

for( [[maybe_unused]] int i : range(10)) {

}


--
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/26aa9d04-42ef-4ce3-892f-88b4337f2d48%40isocpp.org.

------=_Part_2948_492500116.1464994450681
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, June 3, 2016 at 6:37:16 AM UTC-4, schre=
iber...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr">I have defined a utility function &quot;range(n)&quot; that gene=
rates a input sequence of integers from 0 to n-1 such that<br><div style=3D=
"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-sty=
le:solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"c=
olor:#008">for</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#008">int</span><span style=3D"color:#=
000"> i </span><span style=3D"color:#660">:</span><span style=3D"color:#000=
"> range</span><span style=3D"color:#660">(</span><span style=3D"color:#066=
">10</span><span style=3D"color:#660">))</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#800">// ...</span><span style=3D=
"color:#000"><br></span><span style=3D"color:#660">}</span><span style=3D"c=
olor:#000"><br><br></span><span style=3D"color:#800">// Is equivalent to</s=
pan><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">fo=
r</span><span style=3D"color:#000"> </span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#008">int</span><span style=3D"color:#000"> i </spa=
n><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#066">0</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"> i </span><span style=3D"color:#660">&lt;</span><span =
style=3D"color:#000"> </span><span style=3D"color:#066">10</span><span styl=
e=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">++</span><span style=3D"color:#000">i</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#660">}</span><span style=3D"color:#000"><br></span></div></co=
de></div><br>I think a similar utility is present in the range TS, although=
 I do not know it exact name.<br><br>I recently encountered a situation whe=
n I needed to perform &quot;n&quot; iterations, but without caring about &q=
uot;which&quot; iteration is currently being performed; I didn&#39;t use th=
e value of &quot;i&quot; in the example above. The problem is, compilers st=
art warning on unused variable... See running code here: <a href=3D"http://=
cpp.sh/9lot" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D=
&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcpp.sh%2F9lot\x26sa\x3dD\x=
26sntz\x3d1\x26usg\x3dAFQjCNGgjp0QYalkH9xI_ig4lgC-b_GXQA&#39;;return true;"=
 onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcp=
p.sh%2F9lot\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGgjp0QYalkH9xI_ig4lgC-b=
_GXQA&#39;;return true;">http://cpp.sh/9lot</a><br><br>Obviously there are =
various ways around this, in particular using the traditional for loop does=
 not generate a warning. But range-based for loops are superior in many way=
s, and it would be good to be able to use it in this situation. I also thin=
k the warning is correct, since there is no way for the compiler to know yo=
ur intention here (maybe you just made a typo and intended to use &quot;i&q=
uot;?). Therefore, do you think it would be possible to solve this issue by=
 allowing the range variable to be unnamed? Something like:<br><br><div sty=
le=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);borde=
r-style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#008">for</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">(</span><span style=3D"color:#008">int</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">:</span><span style=3D"color:#=
000"> range</span><span style=3D"color:#660">(</span><span style=3D"color:#=
066">10</span><span style=3D"color:#660">))</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// ...</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br></span></div></code></div><br>That would also make one&=
#39;s intention clearer.<br></div></blockquote><div><br></div><div>for( [[m=
aybe_unused]] int i : range(10)) {</div><div><br></div><div>}</div><div>=C2=
=A0</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/26aa9d04-42ef-4ce3-892f-88b4337f2d48%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/26aa9d04-42ef-4ce3-892f-88b4337f2d48=
%40isocpp.org</a>.<br />

------=_Part_2948_492500116.1464994450681--

------=_Part_2947_1027923243.1464994450681--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 3 Jun 2016 22:27:08 -0500
Raw View
--94eb2c1164565b9b3505346b6c95
Content-Type: text/plain; charset=UTF-8

On 3 June 2016 at 05:37, <schreiber.corentin@gmail.com> wrote:

>
> Obviously there are various ways around this, in particular using the
> traditional for loop does not generate a warning.
>

Yes, and IMO it doesn't come up often enough to warrant a language change.
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  +1-847-691-1404

--
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/CAGg_6%2BPTEEXrhRtbjnFhe58x%2B%2BXQ3eR1bETK05mFTH2xSg48pQ%40mail.gmail.com.

--94eb2c1164565b9b3505346b6c95
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 3 June 2016 at 05:37,  <span dir=3D"ltr">&lt;<a href=3D=
"mailto:schreiber.corentin@gmail.com" target=3D"_blank">schreiber.corentin@=
gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><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>Obviously=
 there are various ways around this, in particular using the traditional fo=
r loop does not generate a warning. </div></blockquote><div><br></div><div>=
Yes, and IMO it doesn&#39;t come up often enough to warrant a language chan=
ge.</div></div>-- <br><div class=3D"gmail_signature" data-smartmail=3D"gmai=
l_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin &quot;=
:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" =
target=3D"_blank">nevin@eviloverlord.com</a>&gt; =C2=A0+1-847-691-1404</div=
></div></div></div></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/CAGg_6%2BPTEEXrhRtbjnFhe58x%2B%2BXQ3e=
R1bETK05mFTH2xSg48pQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BPT=
EEXrhRtbjnFhe58x%2B%2BXQ3eR1bETK05mFTH2xSg48pQ%40mail.gmail.com</a>.<br />

--94eb2c1164565b9b3505346b6c95--

.


Author: Sam Kellett <samkellett@gmail.com>
Date: Sat, 4 Jun 2016 12:56:47 +0100
Raw View
--001a1130d27cae4b9005347288c2
Content-Type: text/plain; charset=UTF-8

On 4 June 2016 at 04:27, Nevin Liber <nevin@eviloverlord.com> wrote:

> On 3 June 2016 at 05:37, <schreiber.corentin@gmail.com> wrote:
>
>>
>> Obviously there are various ways around this, in particular using the
>> traditional for loop does not generate a warning.
>>
>
> Yes, and IMO it doesn't come up often enough to warrant a language change.
> --
>  Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  +1-847-691-1404
>
> different styles i guess but it definitely comes up enough for me. and i
think will for even more too when the range ts is accepted and the std::
equivalent of boost::irange is preferred to for(..; ..; ..).

i'd be okay with something like:

    for (std::ignore : range(10)) {
      // ...
    }

but really i think a wildcard symbol for unused variables (ala googletest,
python, etc...) would be best general solution to this and much more.

--
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/CAHK%2B-Ft4jtCy2hPfW3KZrTXZbQnuocTdiiOGut%3DbxqiejanZSA%40mail.gmail.com.

--001a1130d27cae4b9005347288c2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 4 June 2016 at 04:27, Nevin Liber <span dir=3D"ltr">&lt=
;<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@evilover=
lord.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"=
gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D=
"">On 3 June 2016 at 05:37,  <span dir=3D"ltr">&lt;<a href=3D"mailto:schrei=
ber.corentin@gmail.com" target=3D"_blank">schreiber.corentin@gmail.com</a>&=
gt;</span> wrote:<br></span><div class=3D"gmail_extra"><div class=3D"gmail_=
quote"><span class=3D""><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=
>Obviously there are various ways around this, in particular using the trad=
itional for loop does not generate a warning. </div></blockquote><div><br><=
/div></span><div>Yes, and IMO it doesn&#39;t come up often enough to warran=
t a language change.</div></div>-- <br><div data-smartmail=3D"gmail_signatu=
re"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin &quot;:-)&quot;=
 Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D=
"_blank">nevin@eviloverlord.com</a>&gt; =C2=A0<a href=3D"tel:%2B1-847-691-1=
404" value=3D"+18476911404" target=3D"_blank">+1-847-691-1404</a></div></di=
v></div></div></div>
</div></div><span class=3D"">

<p></p>

</span></blockquote><div>different styles i guess but it definitely comes u=
p enough for me. and i think will for even more too when the range ts is ac=
cepted and the std:: equivalent of boost::irange is preferred to for(..; ..=
; ..).<br><br></div><div>i&#39;d be okay with something like:<br><br></div>=
<div>=C2=A0=C2=A0=C2=A0 for (std::ignore : range(10)) {<br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 // ...<br>=C2=A0=C2=A0=C2=A0 }<br><br></div><div>but really=
 i think a wildcard symbol for unused variables (ala googletest, python, et=
c...) would be best general solution to this and much more.<br></div></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/CAHK%2B-Ft4jtCy2hPfW3KZrTXZbQnuocTdii=
OGut%3DbxqiejanZSA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHK%2B-Ft4jt=
Cy2hPfW3KZrTXZbQnuocTdiiOGut%3DbxqiejanZSA%40mail.gmail.com</a>.<br />

--001a1130d27cae4b9005347288c2--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 5 Jun 2016 07:38:42 -0700 (PDT)
Raw View
------=_Part_3043_1283993770.1465137522555
Content-Type: multipart/alternative;
 boundary="----=_Part_3044_296234775.1465137522555"

------=_Part_3044_296234775.1465137522555
Content-Type: text/plain; charset=UTF-8

On Saturday, June 4, 2016 at 7:56:50 AM UTC-4, Sam Kellett wrote:
>
> On 4 June 2016 at 04:27, Nevin Liber <ne...@eviloverlord.com <javascript:>
> > wrote:
>
>> On 3 June 2016 at 05:37, <schreiber...@gmail.com <javascript:>> wrote:
>>
>>>
>>> Obviously there are various ways around this, in particular using the
>>> traditional for loop does not generate a warning.
>>>
>>
>> Yes, and IMO it doesn't come up often enough to warrant a language change.
>> --
>>  Nevin ":-)" Liber  <mailto:ne...@eviloverlord.com <javascript:>>
>> +1-847-691-1404
>>
>> different styles i guess but it definitely comes up enough for me. and i
> think will for even more too when the range ts is accepted and the std::
> equivalent of boost::irange is preferred to for(..; ..; ..).
>

I have written, I'm going to go with thousands of `for` loops. Pre-range
for loops.

I cannot recall a single time where I didn't use the loop counter somewhere
in the body. So I don't see this suddenly becoming very popular with ranges.

BTW, the current version of the Range TS doesn't include a range for
anything like this. It's mainly focused on concepts and algorithms. The
next version should include more range types, adapters, and so forth.


> but really i think a wildcard symbol for unused variables (ala googletest,
> python, etc...) would be best general solution to this and much more.
>

Now that, we can talk about. There are plenty of times where it is
decidedly useful to create a variable and never access it. This would be
for cases when you want the destructor to do some cleanup work.
`scope_exit` and such things. In those cases, there is no need to name the
variable.

Permitting such nameless variables in a range-for would be appropriate.

--
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/ee5f1011-d641-4ec9-8b29-85277fac28fd%40isocpp.org.

------=_Part_3044_296234775.1465137522555
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Saturday, June 4, 2016 at 7:56:50 AM UTC-4, Sam Kellett=
 wrote:<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">On 4 J=
une 2016 at 04:27, Nevin Liber <span dir=3D"ltr">&lt;<a href=3D"javascript:=
" target=3D"_blank" gdf-obfuscated-mailto=3D"gK5SY9CWAQAJ" rel=3D"nofollow"=
 onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"=
this.href=3D&#39;javascript:&#39;;return true;">ne...@eviloverlord.com</a>&=
gt;</span> wrote:<br><div><div class=3D"gmail_quote"><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><span>On 3 June 2016 at 05:37,  <span dir=3D"ltr"=
>&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"gK5=
SY9CWAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39=
;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">=
schreiber...@gmail.com</a>&gt;</span> wrote:<br></span><div><div class=3D"g=
mail_quote"><span><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>Obvio=
usly there are various ways around this, in particular using the traditiona=
l for loop does not generate a warning. </div></blockquote><div><br></div><=
/span><div>Yes, and IMO it doesn&#39;t come up often enough to warrant a la=
nguage change.</div></div>-- <br><div><div dir=3D"ltr"><div><div dir=3D"ltr=
"><div>=C2=A0Nevin &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"gK5SY9CWAQAJ" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclic=
k=3D"this.href=3D&#39;javascript:&#39;;return true;">ne...@eviloverlord.com=
</a><wbr>&gt; =C2=A0<a value=3D"+18476911404">+1-847-691-1404</a></div></di=
v></div></div></div>
</div></div><span>

<p></p>

</span></blockquote><div>different styles i guess but it definitely comes u=
p enough for me. and i think will for even more too when the range ts is ac=
cepted and the std:: equivalent of boost::irange is preferred to for(..; ..=
; ..).<br></div></div></div></div></blockquote><div><br>I have written, I&#=
39;m going to go with thousands of `for` loops. Pre-range for loops.<br><br=
>I cannot recall a single time where I didn&#39;t use the loop counter some=
where in the body. So I don&#39;t see this suddenly becoming very popular w=
ith ranges.<br><br>BTW, the current version of the Range TS doesn&#39;t inc=
lude a range for anything like this. It&#39;s mainly focused on concepts an=
d algorithms. The next version should include more range types, adapters, a=
nd so forth.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr"><div><div class=3D"gmail_quote"><div></div><div>but really i=
 think a wildcard symbol for unused variables (ala googletest, python, etc.=
...) would be best general solution to this and much more.<br></div></div></=
div></div></blockquote><div><br>Now that, we can talk about. There are plen=
ty of times where it is decidedly useful to create a variable and never acc=
ess it. This would be for cases when you want the destructor to do some cle=
anup work. `scope_exit` and such things. In those cases, there is no need t=
o name the variable.<br><br>Permitting such nameless variables in a range-f=
or would be appropriate.<br></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/ee5f1011-d641-4ec9-8b29-85277fac28fd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ee5f1011-d641-4ec9-8b29-85277fac28fd=
%40isocpp.org</a>.<br />

------=_Part_3044_296234775.1465137522555--

------=_Part_3043_1283993770.1465137522555--

.


Author: Viacheslav Usov <via.usov@gmail.com>
Date: Mon, 6 Jun 2016 12:03:16 +0200
Raw View
--001a11401d486a9fbe0534992e40
Content-Type: text/plain; charset=UTF-8

On Sun, Jun 5, 2016 at 4:38 PM, Nicol Bolas <jmckesson@gmail.com> wrote:

> There are plenty of times where it is decidedly useful to create a
variable and never access it. This would be for cases when you want the
destructor to do some cleanup work. `scope_exit` and such things. In those
cases, there is no need to name the variable.

There was a thread a while ago (or was it this same thread?) that also
started with nameless loop variables and ended up with, or made a major
detour into, nameless scope guards. I'm not sure what the conclusion was. I
think I said it then, and I will repeat again, that I generally concur with
your assessment: nameless loop variables are not that useful, while
nameless scope guards would be very nice to have; if they can double as
nameless loop variables, well, OK. Doing it otherwise, i.e., having
nameless loop vars but no nameless scope guards would only be adding
baroqueness to the language.

Cheers,
V.

--
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/CAA7YVg3%3D2VFr8oV3xtf2Q%2BDk%2B%2B-Bd4R_mBnyr55%2Bcv_5BLgonw%40mail.gmail.com.

--001a11401d486a9fbe0534992e40
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
un, Jun 5, 2016 at 4:38 PM, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</sp=
an> wrote:<br><div><br></div><div>&gt; There are plenty of times where it i=
s decidedly useful to create a variable and never access it. This would be =
for cases when you want the destructor to do some cleanup work. `scope_exit=
` and such things. In those cases, there is no need to name the variable.</=
div><div><br></div><div>There was a thread a while ago (or was it this same=
 thread?) that also started with nameless loop variables and ended up with,=
 or made a major detour into, nameless scope guards. I&#39;m not sure what =
the conclusion was. I think I said it then, and I will repeat again, that I=
 generally concur with your assessment: nameless loop variables are not tha=
t useful, while nameless scope guards would be very nice to have; if they c=
an double as nameless loop variables, well, OK. Doing it otherwise, i.e., h=
aving nameless loop vars but no nameless scope guards would only be adding =
baroqueness to the language.</div><div><br></div><div>Cheers,<br></div><div=
>V.</div></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/CAA7YVg3%3D2VFr8oV3xtf2Q%2BDk%2B%2B-B=
d4R_mBnyr55%2Bcv_5BLgonw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Df=
ooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAA7YVg=
3%3D2VFr8oV3xtf2Q%2BDk%2B%2B-Bd4R_mBnyr55%2Bcv_5BLgonw%40mail.gmail.com</a>=
..<br />

--001a11401d486a9fbe0534992e40--

.


Author: Sam Kellett <samkellett@gmail.com>
Date: Mon, 6 Jun 2016 11:19:19 +0100
Raw View
--001a1148ee36d2437d053499674f
Content-Type: text/plain; charset=UTF-8

On 5 June 2016 at 15:38, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Saturday, June 4, 2016 at 7:56:50 AM UTC-4, Sam Kellett wrote:
>>
>> On 4 June 2016 at 04:27, Nevin Liber <ne...@eviloverlord.com> wrote:
>>
>>> On 3 June 2016 at 05:37, <schreiber...@gmail.com> wrote:
>>>
>>>>
>>>> Obviously there are various ways around this, in particular using the
>>>> traditional for loop does not generate a warning.
>>>>
>>>
>>> Yes, and IMO it doesn't come up often enough to warrant a language
>>> change.
>>> --
>>>  Nevin ":-)" Liber  <mailto:ne...@eviloverlord.com>  +1-847-691-1404
>>>
>>> different styles i guess but it definitely comes up enough for me. and i
>> think will for even more too when the range ts is accepted and the std::
>> equivalent of boost::irange is preferred to for(..; ..; ..).
>>
>
> I have written, I'm going to go with thousands of `for` loops. Pre-range
> for loops.
>
> I cannot recall a single time where I didn't use the loop counter
> somewhere in the body. So I don't see this suddenly becoming very popular
> with ranges.
>

do you make a point of remembering details about every for loop you write
or are you assuming that nothing distinct in memory means never done? if
the former: how many times have you used the variable once? how about twice?

--
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/CAHK%2B-FtS3%2BQmbotLiVXbV%3DQjrNAi0wVhaJ6UPs0jVa2tp8ii5A%40mail.gmail.com.

--001a1148ee36d2437d053499674f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 5 June 2016 at 15:38, Nicol Bolas <span dir=3D"ltr">&lt=
;<a href=3D"mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.c=
om</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><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">On Saturday, June 4,=
 2016 at 7:56:50 AM UTC-4, Sam Kellett wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr">On 4 June 2016 at 04:27, Nevin Liber <span dir=
=3D"ltr">&lt;<a rel=3D"nofollow">ne...@eviloverlord.com</a>&gt;</span> wrot=
e:<br><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><span class=3D""><span>On 3 June 2016 at 05:37,  <span dir=3D"lt=
r">&lt;<a rel=3D"nofollow">schreiber...@gmail.com</a>&gt;</span> wrote:<br>=
</span></span><div><span class=3D""><div class=3D"gmail_quote"><span><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
 solid;padding-left:1ex"><div dir=3D"ltr"><br>Obviously there are various w=
ays around this, in particular using the traditional for loop does not gene=
rate a warning. </div></blockquote><div><br></div></span><div>Yes, and IMO =
it doesn&#39;t come up often enough to warrant a language change.</div></di=
v>-- <br></span><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevi=
n &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a rel=3D"nofollow">ne...@evilover=
lord.com</a>&gt; =C2=A0<a value=3D"+18476911404">+1-847-691-1404</a></div><=
/div></div></div></div>
</div></div><span>

<p></p>

</span></blockquote><span class=3D""><div>different styles i guess but it d=
efinitely comes up enough for me. and i think will for even more too when t=
he range ts is accepted and the std:: equivalent of boost::irange is prefer=
red to for(..; ..; ..).<br></div></span></div></div></div></blockquote><div=
><br>I have written, I&#39;m going to go with thousands of `for` loops. Pre=
-range for loops.<br><br>I cannot recall a single time where I didn&#39;t u=
se the loop counter somewhere in the body. So I don&#39;t see this suddenly=
 becoming very popular with ranges.<br></div></div></blockquote><div><br></=
div><div>do you make a point of remembering details about every for loop yo=
u write or are you assuming that nothing distinct in memory means never don=
e? if the former: how many times have you used the variable once? how about=
 twice?</div></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/CAHK%2B-FtS3%2BQmbotLiVXbV%3DQjrNAi0w=
VhaJ6UPs0jVa2tp8ii5A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHK%2B-FtS=
3%2BQmbotLiVXbV%3DQjrNAi0wVhaJ6UPs0jVa2tp8ii5A%40mail.gmail.com</a>.<br />

--001a1148ee36d2437d053499674f--

.


Author: schreiber.corentin@gmail.com
Date: Wed, 8 Jun 2016 12:09:22 -0700 (PDT)
Raw View
------=_Part_4891_1393277823.1465412962667
Content-Type: multipart/alternative;
 boundary="----=_Part_4892_2047836142.1465412962667"

------=_Part_4892_2047836142.1465412962667
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le lundi 6 juin 2016 12:03:19 UTC+2, Viacheslav Usov a =C3=A9crit :
>
> There was a thread a while ago (or was it this same thread?) that also=20
> started with nameless loop variables and ended up with, or made a major=
=20
> detour into, nameless scope guards. I'm not sure what the conclusion was.=
 I=20
> think I said it then, and I will repeat again, that I generally concur wi=
th=20
> your assessment: nameless loop variables are not that useful, while=20
> nameless scope guards would be very nice to have; if they can double as=
=20
> nameless loop variables, well, OK. Doing it otherwise, i.e., having=20
> nameless loop vars but no nameless scope guards would only be adding=20
> baroqueness to the language.
>

Right, you are probably referring to this thread:=20
https://groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/loop/=
std-proposals/ioi76TkG6g4/uwLnH266AQAJ
Sorry I failed to find it before... I agree with your conclusion and=20
Nicol's, I was just reporting a single use case, but a generic solution for=
=20
unnamed variables would be very more useful.

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/e178129d-44f5-4431-bb13-e11a89b88b06%40isocpp.or=
g.

------=_Part_4892_2047836142.1465412962667
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Le lundi 6 juin 2016 12:03:19 UTC+2, Viacheslav Usov a =C3=
=A9crit=C2=A0:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
><div><div class=3D"gmail_quote"><div>There was a thread a while ago (or wa=
s it this same thread?) that also started with nameless loop variables and =
ended up with, or made a major detour into, nameless scope guards. I&#39;m =
not sure what the conclusion was. I think I said it then, and I will repeat=
 again, that I generally concur with your assessment: nameless loop variabl=
es are not that useful, while nameless scope guards would be very nice to h=
ave; if they can double as nameless loop variables, well, OK. Doing it othe=
rwise, i.e., having nameless loop vars but no nameless scope guards would o=
nly be adding baroqueness to the language.</div></div></div></div></blockqu=
ote><div><br>Right, you are probably referring to this thread: <br>https://=
groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/loop/std-prop=
osals/ioi76TkG6g4/uwLnH266AQAJ<br>Sorry I failed to find it before... I agr=
ee with your conclusion and Nicol&#39;s, I was just reporting a single use =
case, but a generic solution for unnamed variables would be very more usefu=
l.<br></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/e178129d-44f5-4431-bb13-e11a89b88b06%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e178129d-44f5-4431-bb13-e11a89b88b06=
%40isocpp.org</a>.<br />

------=_Part_4892_2047836142.1465412962667--

------=_Part_4891_1393277823.1465412962667--

.