Topic: Folding functions almost perfect
Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Thu, 4 Feb 2016 11:17:28 -0800 (PST)
Raw View
------=_Part_1518_1001402477.1454613448797
Content-Type: multipart/alternative;
boundary="----=_Part_1519_1690343705.1454613448798"
------=_Part_1519_1690343705.1454613448798
Content-Type: text/plain; charset=UTF-8
Do we have a proposal to allow this :
1.
2.
1. template<typename F, typename... T>
2. void for_each(F fun, T&&... args)
3. {
4. fun(std::forward<T>(args))...;
5. }
instead of this:
1. template<typename F, typename... T>
2. void for_each(F fun, T&&... args)
3. {
4. (fun (std::forward<T>(args)), ...);
5. }
Don't get me wrong, I love to have one line in the body of for_each, but
this ',' hack is a bit ugly and also I could stop to need to explain this
<http://stackoverflow.com/questions/30819547/why-doesnt-a-left-fold-expression-invert-the-output-of-a-right-fold-expression> to
my friends :)
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1519_1690343705.1454613448798
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Do we have a proposal to allow this :<div><ol class=3D"lin=
enums" style=3D"padding: 0px; border: 0px; font-stretch: inherit; font-fami=
ly: Consolas, 'Courier New', 'Lucida Console', monospace; f=
ont-size: 12px; vertical-align: baseline; list-style: none; color: rgb(187,=
187, 187); white-space: pre; background: none;"><li class=3D"L0" style=3D"=
margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: =
inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit;=
font-family: inherit; vertical-align: baseline; list-style-type: none; min=
-height: 1em; background: none;"><div style=3D"color: rgb(34, 34, 34); font=
-family: Arial, Helvetica, sans-serif; font-size: 13px; white-space: normal=
;"><br></div></li><li class=3D"L0" style=3D"margin: 0px; padding: 0px; bord=
er: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; =
font-stretch: inherit; line-height: inherit; font-family: inherit; vertical=
-align: baseline; list-style-type: none; min-height: 1em; background: none;=
"><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187);=
word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><ol class=3D"linenums" style=
=3D"padding: 0px; border: 0px; font-stretch: inherit; font-family: Consolas=
, 'Courier New', 'Lucida Console', monospace; vertical-alig=
n: baseline; list-style: none; background: none;"><li class=3D"L0" style=3D=
"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant:=
inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit=
; font-family: inherit; vertical-align: baseline; list-style-type: none; mi=
n-height: 1em; background: none;"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> F</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">></span></li><li class=3D"L1" sty=
le=3D"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-var=
iant: inherit; font-weight: inherit; font-stretch: inherit; line-height: in=
herit; font-family: inherit; vertical-align: baseline; list-style-type: non=
e; min-height: 1em; background: none;"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> for_each</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">F fun</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&&...<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> args</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span></li><li=
class=3D"L2" style=3D"margin: 0px; padding: 0px; border: 0px; font-style: =
inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit=
; line-height: inherit; font-family: inherit; vertical-align: baseline; lis=
t-style-type: none; min-height: 1em; background: none;"><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span></li><li class=3D"L3" style=
=3D"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-varia=
nt: inherit; font-weight: inherit; font-stretch: inherit; line-height: inhe=
rit; font-family: inherit; vertical-align: baseline; list-style-type: none;=
min-height: 1em; background: none;"><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> =C2=A0 =C2=A0fun</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><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">forward</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">>(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">args</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">))...;</span></li><li clas=
s=3D"L4" style=3D"margin: 0px; padding: 0px; border: 0px; font-style: inher=
it; font-variant: inherit; font-weight: inherit; font-stretch: inherit; lin=
e-height: inherit; font-family: inherit; vertical-align: baseline; min-heig=
ht: 1em;"><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
></li></ol></div></code></div><br><div style=3D"color: rgb(34, 34, 34); fon=
t-family: Arial, Helvetica, sans-serif; font-size: 13px; white-space: norma=
l;">instead of this:=C2=A0</div></li></ol></div><div><div class=3D"prettypr=
int" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><ol class=3D"linenums" style=3D"margin: 0px; padding:=
0px; border: 0px; font-stretch: inherit; font-family: Consolas, 'Couri=
er New', 'Lucida Console', monospace; font-size: 12px; vertical=
-align: baseline; list-style: none; color: rgb(187, 187, 187); white-space:=
pre; background: none;"><li class=3D"L0" style=3D"margin: 0px; padding: 0p=
x; border: 0px; font-style: inherit; font-variant: inherit; font-weight: in=
herit; font-stretch: inherit; line-height: inherit; font-family: inherit; v=
ertical-align: baseline; list-style-type: none; min-height: 1em; background=
: none;"><span style=3D"color: #008;" class=3D"styled-by-prettify">template=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">></span></li><li class=3D"L1" style=3D"margin: 0px; padd=
ing: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-wei=
ght: inherit; font-stretch: inherit; line-height: inherit; font-family: inh=
erit; vertical-align: baseline; list-style-type: none; min-height: 1em; bac=
kground: none;"><span style=3D"color: #008;" class=3D"styled-by-prettify">v=
oid</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> for_ea=
ch</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">F fun</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&&...</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> args</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">)</span></li><li class=3D"L2" style=3D"ma=
rgin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: in=
herit; font-weight: inherit; font-stretch: inherit; line-height: inherit; f=
ont-family: inherit; vertical-align: baseline; list-style-type: none; min-h=
eight: 1em; background: none;"><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span></li><li class=3D"L3" style=3D"margin: 0px; padding: =
0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: =
inherit; font-stretch: inherit; line-height: inherit; font-family: inherit;=
vertical-align: baseline; list-style-type: none; min-height: 1em; backgrou=
nd: none;"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=
=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">fun </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">forward</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">>(</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">args</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)),</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...);</sp=
an></li><li class=3D"L4" style=3D"margin: 0px; padding: 0px; border: 0px; f=
ont-style: inherit; font-variant: inherit; font-weight: inherit; font-stret=
ch: inherit; line-height: inherit; font-family: inherit; vertical-align: ba=
seline; min-height: 1em;"><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</span></li></ol></div></code></div><div><br></div></div><div>Don=
't get me wrong, I love to have one line in the body of for_each, but t=
his ',' hack is a bit ugly and also I could stop to need to explain=
<a href=3D"http://stackoverflow.com/questions/30819547/why-doesnt-a-left-f=
old-expression-invert-the-output-of-a-right-fold-expression">this</a>=C2=A0=
to my friends :)</div><div><br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_1519_1690343705.1454613448798--
------=_Part_1518_1001402477.1454613448797--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 4 Feb 2016 12:01:20 -0800
Raw View
--001a1143e99cc5f8aa052af7328e
Content-Type: text/plain; charset=UTF-8
On Thu, Feb 4, 2016 at 11:17 AM, Cleiton Santoia <cleitonsantoia@gmail.com>
wrote:
> Do we have a proposal to allow this :
>
> 1.
> 2.
> 1. template<typename F, typename... T>
> 2. void for_each(F fun, T&&... args)
> 3. {
> 4. fun(std::forward<T>(args))...;
> 5. }
>
> instead of this:
>
>
> 1. template<typename F, typename... T>
> 2. void for_each(F fun, T&&... args)
> 3. {
> 4. (fun (std::forward<T>(args)), ...);
> 5. }
>
>
> Don't get me wrong, I love to have one line in the body of for_each, but
> this ',' hack is a bit ugly and also I could stop to need to explain this
> <http://stackoverflow.com/questions/30819547/why-doesnt-a-left-fold-expression-invert-the-output-of-a-right-fold-expression> to
> my friends :)
>
I don't know of such a proposal, but it seems eminently reasonable to me.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a1143e99cc5f8aa052af7328e
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 T=
hu, Feb 4, 2016 at 11:17 AM, Cleiton Santoia <span dir=3D"ltr"><<a href=
=3D"mailto:cleitonsantoia@gmail.com" target=3D"_blank">cleitonsantoia@gmail=
..com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r">Do we have a proposal to allow this :<div><ol style=3D"padding:0px;borde=
r:0px;font-stretch:inherit;font-family:Consolas,'Courier New','=
Lucida Console',monospace;font-size:12px;vertical-align:baseline;list-s=
tyle:none;color:rgb(187,187,187);white-space:pre-wrap;background:none"><li =
style=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:=
inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-f=
amily:inherit;vertical-align:baseline;list-style-type:none;min-height:1em;b=
ackground:none"><div style=3D"color:rgb(34,34,34);font-family:Arial,Helveti=
ca,sans-serif;font-size:13px;white-space:normal"><br></div></li><li style=
=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inher=
it;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family=
:inherit;vertical-align:baseline;list-style-type:none;min-height:1em;backgr=
ound:none"><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-=
word;background-color:rgb(250,250,250)"><code><div><ol style=3D"padding:0px=
;border:0px;font-stretch:inherit;font-family:Consolas,'Courier New'=
,'Lucida Console',monospace;vertical-align:baseline;list-style:none=
;background:none"><li style=3D"margin:0px;padding:0px;border:0px;font-style=
:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line=
-height:inherit;font-family:inherit;vertical-align:baseline;list-style-type=
:none;min-height:1em;background:none"><span style=3D"color:#008">template</=
span><span style=3D"color:#660"><</span><span style=3D"color:#008">typen=
ame</span><span style=3D"color:#000"> F</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#008">typenam=
e</span><span style=3D"color:#660">...</span><span style=3D"color:#000"> T<=
/span><span style=3D"color:#660">></span></li><li style=3D"margin:0px;pa=
dding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:in=
herit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical=
-align:baseline;list-style-type:none;min-height:1em;background:none"><span =
style=3D"color:#008">void</span><span style=3D"color:#000"> for_each</span>=
<span style=3D"color:#660">(</span><span style=3D"color:#000">F fun</span><=
span style=3D"color:#660">,</span><span style=3D"color:#000"> T</span><span=
style=3D"color:#660">&&...</span><span style=3D"color:#000"> args<=
/span><span style=3D"color:#660">)</span></li><li style=3D"margin:0px;paddi=
ng:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-al=
ign:baseline;list-style-type:none;min-height:1em;background:none"><span sty=
le=3D"color:#660">{</span></li><li style=3D"margin:0px;padding:0px;border:0=
px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch=
:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;li=
st-style-type:none;min-height:1em;background:none"><span style=3D"color:#00=
0"> =C2=A0 =C2=A0fun</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">forward</span><span style=3D"color:#660"><</span><span s=
tyle=3D"color:#000">T</span><span style=3D"color:#660">>(</span><span st=
yle=3D"color:#000">args</span><span style=3D"color:#660">))...;</span></li>=
<li style=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-vari=
ant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;min-height:1em"><span style=3D"co=
lor:#660">}</span></li></ol></div></code></div><br><div style=3D"color:rgb(=
34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:13px;white-space=
:normal">instead of this:=C2=A0</div></li></ol></div><div><div style=3D"bor=
der:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(25=
0,250,250)"><code><div><ol style=3D"margin:0px;padding:0px;border:0px;font-=
stretch:inherit;font-family:Consolas,'Courier New','Lucida Cons=
ole',monospace;font-size:12px;vertical-align:baseline;list-style:none;c=
olor:rgb(187,187,187);white-space:pre-wrap;background:none"><li style=3D"ma=
rgin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;fon=
t-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;list-style-type:none;min-height:1em;background:n=
one"><span style=3D"color:#008">template</span><span style=3D"color:#660">&=
lt;</span><span style=3D"color:#008">typename</span><span style=3D"color:#0=
00"> F</span><span style=3D"color:#660">,</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">typename</span><span style=3D"color:#660=
">...</span><span style=3D"color:#000"> T</span><span style=3D"color:#660">=
></span></li><li style=3D"margin:0px;padding:0px;border:0px;font-style:i=
nherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-h=
eight:inherit;font-family:inherit;vertical-align:baseline;list-style-type:n=
one;min-height:1em;background:none"><span style=3D"color:#008">void</span><=
span style=3D"color:#000"> for_each</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#000">F fun</span><span style=3D"color:#660">,</span=
><span style=3D"color:#000"> T</span><span style=3D"color:#660">&&.=
...</span><span style=3D"color:#000"> args</span><span style=3D"color:#660">=
)</span></li><li style=3D"margin:0px;padding:0px;border:0px;font-style:inhe=
rit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-heig=
ht:inherit;font-family:inherit;vertical-align:baseline;list-style-type:none=
;min-height:1em;background:none"><span style=3D"color:#660">{</span></li><l=
i style=3D"margin:0px;padding:0px;border:0px;font-style:inherit;font-varian=
t:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font=
-family:inherit;vertical-align:baseline;list-style-type:none;min-height:1em=
;background:none"><span style=3D"color:#000"> =C2=A0 =C2=A0</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#000">fun </span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">std</span><span style=3D=
"color:#660">::</span><span style=3D"color:#000">forward</span><span style=
=3D"color:#660"><</span><span style=3D"color:#000">T</span><span style=
=3D"color:#660">>(</span><span style=3D"color:#000">args</span><span sty=
le=3D"color:#660">)),</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">...);</span></li><li style=3D"margin:0px;padding:0px;border=
:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stret=
ch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;=
min-height:1em"><span style=3D"color:#660">}</span></li></ol></div></code><=
/div><div><br></div></div><div>Don't get me wrong, I love to have one l=
ine in the body of for_each, but this ',' hack is a bit ugly and al=
so I could stop to need to explain <a href=3D"http://stackoverflow.com/ques=
tions/30819547/why-doesnt-a-left-fold-expression-invert-the-output-of-a-rig=
ht-fold-expression" target=3D"_blank">this</a>=C2=A0to my friends :)</div><=
/div></blockquote><div><br></div><div>I don't know of such a proposal, =
but it seems eminently reasonable to me.=C2=A0</div></div></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a1143e99cc5f8aa052af7328e--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 04 Feb 2016 14:42:50 -0800
Raw View
On quinta-feira, 4 de fevereiro de 2016 11:17:28 PST Cleiton Santoia wrote:
> Do we have a proposal to allow this :
>
> 1.
> 2.
> 1. template<typename F, typename... T>
> 2. void for_each(F fun, T&&... args)
> 3. {
> 4. fun(std::forward<T>(args))...;
> 5. }
This should be a regular parameter pack expansion, which already adds commas
in things like:
f(args...);
f(std::forward<T>(args)...);
> instead of this:
>
>
> 1. template<typename F, typename... T>
> 2. void for_each(F fun, T&&... args)
> 3. {
> 4. (fun (std::forward<T>(args)), ...);
> 5. }
This, on the other hand, is a fold expression on the comma operator. I don't
understand why the parentheses are required, though.
Also, be careful of evaluation order. See the other thread on this specific
topic:
f(a), f(b)
does not imply f(a) will be called first.
> Don't get me wrong, I love to have one line in the body of for_each, but
> this ',' hack is a bit ugly and also I could stop to need to explain this
> <http://stackoverflow.com/questions/30819547/why-doesnt-a-left-fold-expressi
> on-invert-the-output-of-a-right-fold-expression> to my friends :)
I don't see why an inversion would be even expected. The expansion of a fold
expression is clear, then it's just up to evaluation order.
If the functions returned int and you'd done:
fun(std::forward<T>(args)) + ...;
The evaluation order of addition would apply.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Thu, 4 Feb 2016 14:58:48 -0800
Raw View
--94eb2c094ed072ee7a052af9ad91
Content-Type: text/plain; charset=UTF-8
On Thu, Feb 4, 2016 at 2:42 PM, Thiago Macieira <thiago@macieira.org> wrote:
>
> Also, be careful of evaluation order. See the other thread on this specific
> topic:
>
> f(a), f(b)
>
> does not imply f(a) will be called first.
>
Actually, I'm pretty sure it does guarantee order with the built-in comma
operator, which is somewhat special in this manner. You get order well
defined with comma, &&, ||, ?: and probably something else I'm forgetting
(someone correct me if I'm wrong). This is one reason why you may prefer
comma over argument passing here -- one evaluates from left to right while
the other does not.
That said, there is a gotcha here that is missed -- in generic code such as
the for_each example, you should be casting the operands to void before
applying the comma operator, otherwise you risk pulling in an overload of
comma.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
--94eb2c094ed072ee7a052af9ad91
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 T=
hu, Feb 4, 2016 at 2:42 PM, Thiago Macieira <span dir=3D"ltr"><<a href=
=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org</a>&g=
t;</span> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex">
Also, be careful of evaluation order. See the other thread on this specific=
<br>
topic:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 f(a), f(b)<br>
<br>
does not imply f(a) will be called first.<br></blockquote><div><br></div><d=
iv>Actually, I'm pretty sure it does guarantee order with the built-in =
comma operator, which is somewhat special in this manner. You get order wel=
l defined with comma, &&, ||, ?: and probably something else I'=
m forgetting (someone correct me if I'm wrong). This is one reason why =
you may prefer comma over argument passing here -- one evaluates from left =
to right while the other does not.</div><div><br></div><div>That said, ther=
e is a gotcha here that is missed -- in generic code such as the for_each e=
xample, you should be casting the operands to void before applying the comm=
a operator, otherwise you risk pulling in an overload of comma.</div></div>=
</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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--94eb2c094ed072ee7a052af9ad91--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 4 Feb 2016 15:27:27 -0800
Raw View
--001a11414f48e1513c052afa1369
Content-Type: text/plain; charset=UTF-8
On Thu, Feb 4, 2016 at 2:42 PM, Thiago Macieira <thiago@macieira.org> wrote:
> On quinta-feira, 4 de fevereiro de 2016 11:17:28 PST Cleiton Santoia wrote:
> > Do we have a proposal to allow this :
> >
> > 1.
> > 2.
> > 1. template<typename F, typename... T>
> > 2. void for_each(F fun, T&&... args)
> > 3. {
> > 4. fun(std::forward<T>(args))...;
> > 5. }
>
> This should be a regular parameter pack expansion, which already adds
> commas
> in things like:
>
> f(args...);
> f(std::forward<T>(args)...);
>
> > instead of this:
> >
> >
> > 1. template<typename F, typename... T>
> > 2. void for_each(F fun, T&&... args)
> > 3. {
> > 4. (fun (std::forward<T>(args)), ...);
> > 5. }
>
> This, on the other hand, is a fold expression on the comma operator. I
> don't
> understand why the parentheses are required, though.
>
The parentheses avoid grammar ambiguities in some cases (but not in this
case).
An alternative formulation would be to change the grammar to add a binary $
.... $ operator and unary prefix and postfix ... $ and $ ... operators for
every binary operator $. That'd look like this:
logical-or-expression:
logical-and-expression
logical-or-expression || logical-and-expression
logical-or-expression || ...
... || logical-and-expression
logical-or-expression || ... || logical-and-expression
.... and likewise for every different level of the expression grammar that
adds binary operators. That would resolve this:
a + ... * b
.... as
a + (... * b)
We were careful to choose a grammatical form for fold expressions that
allows this grammatical change in a backwards-compatible way, if there's
demand for it.
Also, be careful of evaluation order. See the other thread on this specific
> topic:
>
> f(a), f(b)
>
> does not imply f(a) will be called first.
Only if it calls an overloaded 'operator,'. It would seem reasonable to
specify that
expression ... ;
is sugar for
( void ( expression ) , ... ) ;
to avoid that.
> Don't get me wrong, I love to have one line in the body of for_each, but
> > this ',' hack is a bit ugly and also I could stop to need to explain this
> > <
> http://stackoverflow.com/questions/30819547/why-doesnt-a-left-fold-expressi
> > on-invert-the-output-of-a-right-fold-expression> to my friends :)
>
> I don't see why an inversion would be even expected. The expansion of a
> fold
> expression is clear, then it's just up to evaluation order.
>
> If the functions returned int and you'd done:
>
> fun(std::forward<T>(args)) + ...;
>
> The evaluation order of addition would apply.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
> --
>
> ---
> 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
> https://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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a11414f48e1513c052afa1369
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 T=
hu, Feb 4, 2016 at 2:42 PM, Thiago Macieira <span dir=3D"ltr"><<a href=
=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
.8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On quin=
ta-feira, 4 de fevereiro de 2016 11:17:28 PST Cleiton Santoia wrote:<br>
> Do we have a proposal to allow this :<br>
><br>
</span>>=C2=A0 =C2=A0 1.<br>
>=C2=A0 =C2=A0 2.<br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A01. template<typename F, typename... T>=
<br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A02. void for_each(F fun, T&&... args)=
<br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A03. {<br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A04.=C2=A0 =C2=A0 fun(std::forward<T>(ar=
gs))...;<br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A05. }<br>
<br>
This should be a regular parameter pack expansion, which already adds comma=
s<br>
in things like:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 f(args...);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 f(std::forward<T>(args)...);<br>
<br>
>=C2=A0 =C2=A0 instead of this:<br>
><br>
><br>
>=C2=A0 =C2=A0 1. template<typename F, typename... T><br>
>=C2=A0 =C2=A0 2. void for_each(F fun, T&&... args)<br>
>=C2=A0 =C2=A0 3. {<br>
>=C2=A0 =C2=A0 4.=C2=A0 =C2=A0 (fun (std::forward<T>(args)), ...);=
<br>
>=C2=A0 =C2=A0 5. }<br>
<br>
This, on the other hand, is a fold expression on the comma operator. I don&=
#39;t<br>
understand why the parentheses are required, though.<br></blockquote><div><=
br></div><div>The parentheses avoid grammar ambiguities in some cases (but =
not in this case).</div><div><br></div><div>An alternative formulation woul=
d be to change the grammar to add a binary $ ... $ operator and unary prefi=
x and postfix ... $ and $ ... operators for every binary operator $. That&#=
39;d look like this:</div><div><br></div><div>=C2=A0 logical-or-expression:=
</div><div>=C2=A0 =C2=A0 logical-and-expression</div><div>=C2=A0 =C2=A0 log=
ical-or-expression || logical-and-expression</div><div>=C2=A0 =C2=A0 logica=
l-or-expression || ...</div><div>=C2=A0 =C2=A0 ... || logical-and-expressio=
n</div><div>=C2=A0 =C2=A0 logical-or-expression || ... || logical-and-expre=
ssion</div><div><br></div><div>... and likewise for every different level o=
f the expression grammar that adds binary operators. That would resolve thi=
s:</div><div><br></div><div>=C2=A0 a + ... * b</div><div><br></div><div>...=
as</div><div><br></div><div>=C2=A0 a + (... * b)</div><div><br></div><div>=
We were careful to choose a grammatical form for fold expressions that allo=
ws this grammatical change in a backwards-compatible way, if there's de=
mand for it.</div><div><br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, be careful of evaluation order. See the other thread on this specific=
<br>
topic:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 f(a), f(b)<br>
<br>
does not imply f(a) will be called first.</blockquote><div><br></div><div>O=
nly if it calls an overloaded 'operator,'. It would seem reasonable=
to specify that</div><div><br></div><div>=C2=A0 expression ... ;</div><div=
><br></div><div>is sugar for</div><div><br></div><div>=C2=A0 ( void ( expre=
ssion ) , ... ) ;</div><div><br></div><div>to avoid that.</div><div><br></d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><span class=3D"">
> Don't get me wrong, I love to have one line in the body of for_eac=
h, but<br>
> this ',' hack is a bit ugly and also I could stop to need to e=
xplain this<br>
</span>> <<a href=3D"http://stackoverflow.com/questions/30819547/why-=
doesnt-a-left-fold-expressi" rel=3D"noreferrer" target=3D"_blank">http://st=
ackoverflow.com/questions/30819547/why-doesnt-a-left-fold-expressi</a><br>
> on-invert-the-output-of-a-right-fold-expression> to my friends :)<b=
r>
<br>
I don't see why an inversion would be even expected. The expansion of a=
fold<br>
expression is clear, then it's just up to evaluation order.<br>
<br>
If the functions returned int and you'd done:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 fun(std::forward<T>(args)) + ...;<br>
<br>
The evaluation order of addition would apply.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"noref=
errer" target=3D"_blank">macieira.info</a> - thiago (AT) <a href=3D"http://=
kde.org" rel=3D"noreferrer" target=3D"_blank">kde.org</a><br>
=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/" rel=3D"noreferrer" target=3D"_blank">https://groups.google=
..com/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a11414f48e1513c052afa1369--
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 5 Feb 2016 09:26:02 +0800
Raw View
--Apple-Mail=_EF98E549-214E-48E0-896C-2962BF9E304C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2016=E2=80=9302=E2=80=9305, at 7:27 AM, Richard Smith <richard@metafoo=
..co.uk> wrote:
>=20
> The parentheses avoid grammar ambiguities in some cases (but not in this =
case).
Wouldn=E2=80=99t swapping the ellipsis and the semicolon be more visually c=
onsistent with fold expressions?
expression; ...
Notionally, the semicolon is repeated by the expansion. ;... could also be =
used for e.g. using and friend declarations.
There would be a syntactic ambiguity with e.g. ...||logical-and-expression,=
but it would be naturally resolved by looking for an ellipsis in the speci=
fic case that an expression-statement contains an unexpected pack, which al=
ready must be detected for the sake of diagnosis.
However, what=E2=80=99s an example of the grammar ambiguity which necessita=
tes parens in a ,...; comma fold? It seems that idiom is already good enoug=
h, and the proposal lacks motivation aside from corner cases and saving a s=
ingle character.
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--Apple-Mail=_EF98E549-214E-48E0-896C-2962BF9E304C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><div><br class=3D"=
"></div><div><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=
=E2=80=9302=E2=80=9305, at 7:27 AM, Richard Smith <<a href=3D"mailto:ric=
hard@metafoo.co.uk" class=3D"">richard@metafoo.co.uk</a>> wrote:</div><b=
r class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" styl=
e=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-vari=
ant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; te=
xt-align: start; text-indent: 0px; text-transform: none; white-space: norma=
l; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=
=3D""><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D""=
>The parentheses avoid grammar ambiguities in some cases (but not in this c=
ase).</div></div></div></div></div></blockquote></div><br class=3D""><div c=
lass=3D""><div>Wouldn=E2=80=99t swapping the ellipsis and the semicolon be =
more visually consistent with fold expressions?</div><div><br class=3D""></=
div><div><font face=3D"Courier" class=3D""> expression; ...</f=
ont></div><div class=3D""><br class=3D""></div><div class=3D"">Notionally, =
the semicolon is repeated by the expansion. <font face=3D"Courier" cla=
ss=3D"">;...</font> could also be used for e.g. <font face=3D"Cou=
rier" class=3D"">using</font> and <font face=3D"Courier" class=3D"">fr=
iend</font> declarations.</div><div class=3D""><br class=3D""></div><d=
iv class=3D"">There would be a syntactic ambiguity with e.g. <font face=3D"=
Courier" class=3D"">...||</font><i class=3D"">logical-and-expression</i>, b=
ut it would be naturally resolved by looking for an ellipsis in the specifi=
c case that an expression-statement contains an unexpected pack, which alre=
ady must be detected for the sake of diagnosis.</div><div class=3D""><br cl=
ass=3D""></div><div class=3D"">However, what=E2=80=99s an example of the gr=
ammar ambiguity which necessitates parens in a <font face=3D"Courier" =
class=3D"">,...;</font> comma fold? It seems that idiom is already goo=
d enough, and the proposal lacks motivation aside from corner cases and sav=
ing a single character.</div></div><div class=3D""><br class=3D""></div></b=
ody></html>
<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--Apple-Mail=_EF98E549-214E-48E0-896C-2962BF9E304C--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 4 Feb 2016 17:42:30 -0800
Raw View
--001a1143ff34e70616052afbf6d4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thu, Feb 4, 2016 at 5:26 PM, David Krauss <potswa@gmail.com> wrote:
>
> On 2016=E2=80=9302=E2=80=9305, at 7:27 AM, Richard Smith <richard@metafoo=
..co.uk> wrote:
>
> The parentheses avoid grammar ambiguities in some cases (but not in this
> case).
>
>
> Wouldn=E2=80=99t swapping the ellipsis and the semicolon be more visually
> consistent with fold expressions?
>
> expression; ...
>
A ... at the end of a statement closes lots of opportunities for future
language extensions (such as removing the parens from fold-expressions, as
you suggest below). We should not do that lightly. Also, semicolon is not a
binary operator, so it doesn't make sense to fold over it. It makes more
sense (I think) to think of this as a normal pack expansion, not a
fold-expression, which would naturally produce
expr$0, expr$1, ..., expr$N;
from
expr...;
Notionally, the semicolon is repeated by the expansion. ;... could also be
> used for e.g. using and friend declarations.
>
> There would be a syntactic ambiguity with e.g. ...||
> *logical-and-expression*, but it would be naturally resolved by looking
> for an ellipsis in the specific case that an expression-statement contain=
s
> an unexpected pack, which already must be detected for the sake of
> diagnosis.
>
> However, what=E2=80=99s an example of the grammar ambiguity which necessi=
tates
> parens in a ,...; comma fold? It seems that idiom is already good enough,
> and the proposal lacks motivation aside from corner cases and saving a
> single character.
>
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--001a1143ff34e70616052afbf6d4
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 T=
hu, Feb 4, 2016 at 5:26 PM, David Krauss <span dir=3D"ltr"><<a href=3D"m=
ailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>></span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"=
><span class=3D""><div><br></div><div><blockquote type=3D"cite"><div>On 201=
6=E2=80=9302=E2=80=9305, at 7:27 AM, Richard Smith <<a href=3D"mailto:ri=
chard@metafoo.co.uk" target=3D"_blank">richard@metafoo.co.uk</a>> wrote:=
</div><br><div><div dir=3D"ltr" style=3D"font-family:Helvetica;font-size:12=
px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:=
normal;text-align:start;text-indent:0px;text-transform:none;white-space:nor=
mal;word-spacing:0px"><div class=3D"gmail_extra"><div class=3D"gmail_quote"=
><div>The parentheses avoid grammar ambiguities in some cases (but not in t=
his case).</div></div></div></div></div></blockquote></div><br></span><div>=
<div>Wouldn=E2=80=99t swapping the ellipsis and the semicolon be more visua=
lly consistent with fold expressions?</div><div><br></div><div><font face=
=3D"Courier">=C2=A0 =C2=A0 expression; ...</font></div></div></div></blockq=
uote><div><br></div><div>A ... at the end of a statement closes lots of opp=
ortunities for future language extensions (such as removing the parens from=
fold-expressions, as you suggest below). We should not do that lightly. Al=
so, semicolon is not a binary operator, so it doesn't make sense to fol=
d over it. It makes more sense (I think) to think of this as a normal pack =
expansion, not a fold-expression, which would naturally produce</div><div><=
br></div><div>=C2=A0 =C2=A0expr$0, expr$1, ..., expr$N;</div><div><br></div=
><div>from</div><div><br></div><div>=C2=A0 expr...;</div><div><br></div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><div><div>N=
otionally, the semicolon is repeated by the expansion.=C2=A0<font face=3D"C=
ourier">;...</font>=C2=A0could also be used for e.g.=C2=A0<font face=3D"Cou=
rier">using</font>=C2=A0and <font face=3D"Courier">friend</font>=C2=A0decla=
rations.</div><div><br></div><div>There would be a syntactic ambiguity with=
e.g. <font face=3D"Courier">...||</font><i>logical-and-expression</i>, but=
it would be naturally resolved by looking for an ellipsis in the specific =
case that an expression-statement contains an unexpected pack, which alread=
y must be detected for the sake of diagnosis.</div><div><br></div><div>Howe=
ver, what=E2=80=99s an example of the grammar ambiguity which necessitates =
parens in a=C2=A0<font face=3D"Courier">,...;</font>=C2=A0comma fold? It se=
ems that idiom is already good enough, and the proposal lacks motivation as=
ide from corner cases and saving a single character.</div></div></div></blo=
ckquote></div></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a1143ff34e70616052afbf6d4--
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 5 Feb 2016 11:14:36 +0800
Raw View
--Apple-Mail=_2790FD9E-66A8-4F38-AF14-7F16470D5195
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2016=E2=80=9302=E2=80=9305, at 9:42 AM, Richard Smith <richard@metafoo=
..co.uk> wrote:
>=20
> A ... at the end of a statement closes lots of opportunities for future l=
anguage extensions (such as removing the parens from fold-expressions, as y=
ou [sic] suggest below). We should not do that lightly.
Ah, I had assumed that the =E2=80=9Calternative formulation=E2=80=9D was eq=
uivalent to the status quo. Now I see that all fold expressions currently m=
ust be parenthesized.
Given the extension for unparenthesized folds, merely omitting the comma in=
,...; seems like a very narrow further extension.
I thought I=E2=80=99d addressed the ambiguity, but indeed it=E2=80=99s subt=
ler. A statement with an unexpanded pack may occur in a lambda, e.g.
template< typename ... arg >
void foo( arg const & ... a ) {
bar( [&] {
baz( a ); // Allowing ;... would require lookahead here: unexpanded=
pack is not a valid hint.
... || a( 42 );
} ... );
}
It=E2=80=99s not clear that the opportunity is closed; this still looks lik=
e just one extra token of lookahead. (Still, that=E2=80=99s a strike agains=
t.) Is there anything more to it?
> Also, semicolon is not a binary operator, so it doesn't make sense to fol=
d over it.
;... certainly wouldn=E2=80=99t be a fold expression. Its advantage is that=
the pattern explicitly appears before the ellipsis.
> It makes more sense (I think) to think of this as a normal pack expansion=
, not a fold-expression, which would naturally produce
>=20
> expr$0, expr$1, ..., expr$N;
>=20
> from
>=20
> expr=E2=80=A6;
Per your previous message, it would be void(expr$0), void(expr$1), void(exp=
r$N);. That seems less natural than {expr$0; expr$1; expr$N;}. But the beha=
vior is equivalent; it=E2=80=99s only a matter of standardese.
In other words, ...; may as well not be a fold expression, either. Seems li=
ke a bit of work just to account for operator, overloads and save one chara=
cter.
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--Apple-Mail=_2790FD9E-66A8-4F38-AF14-7F16470D5195
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9302=
=E2=80=9305, at 9:42 AM, Richard Smith <<a href=3D"mailto:richard@metafo=
o.co.uk" class=3D"">richard@metafoo.co.uk</a>> wrote:</div><br class=3D"=
Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D""><div=
class=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D"">A ... at =
the end of a statement closes lots of opportunities for future language ext=
ensions (such as removing the parens from fold-expressions, as you [sic] su=
ggest below). We should not do that lightly. </div></div></div></div></div>=
</blockquote><div><br class=3D""></div><div>Ah, I had assumed that the =E2=
=80=9Calternative formulation=E2=80=9D was equivalent to the status quo. No=
w I see that all fold expressions currently must be parenthesized.</div><di=
v><br class=3D""></div><div>Given the extension for unparenthesized folds, =
merely omitting the comma in <font face=3D"Courier" class=3D"">,...;</font>=
seems like a very narrow further extension.</div><div><br class=3D""></div=
><div>I thought I=E2=80=99d addressed the ambiguity, but indeed it=E2=80=99=
s subtler. A statement with an unexpanded pack may occur in a lambda, e.g.<=
/div><div><br class=3D""></div><div><font face=3D"Courier" class=3D"">templ=
ate< typename ... arg ></font></div><div><font face=3D"Courier" class=
=3D"">void foo( arg const & ... a ) {</font></div><div><font face=3D"Co=
urier" class=3D""> bar( [&] {</font></div><div><font face=
=3D"Courier" class=3D""> baz( a ); // Allowing ;=
.... would require lookahead here: unexpanded pack is not a valid hint.</fon=
t></div><div><font face=3D"Courier" class=3D""> =
.... || a( 42 );</font></div><div><font face=3D"Courier" class=3D""> &=
nbsp; } ... );</font></div><div><font face=3D"Courier" class=3D"">}</font><=
/div><div><br class=3D""></div><div>It=E2=80=99s not clear that the opportu=
nity is closed; this still looks like just one extra token of lookahead. (S=
till, that=E2=80=99s a strike against.) Is there anything more to it?</div>=
<div><br class=3D""></div><blockquote type=3D"cite" class=3D""><div class=
=3D""><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div class=3D"=
gmail_quote"><div class=3D"">Also, semicolon is not a binary operator, so i=
t doesn't make sense to fold over it. </div></div></div></div></div></block=
quote><div><br class=3D""></div><div><font face=3D"Courier" class=3D"">;...=
</font> certainly wouldn=E2=80=99t be a fold expression. Its advantage=
is that the pattern explicitly appears before the ellipsis.</div><div clas=
s=3D""><br class=3D""></div><blockquote type=3D"cite" class=3D""><div class=
=3D""><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div class=3D"=
gmail_quote"><div class=3D"">It makes more sense (I think) to think of this=
as a normal pack expansion, not a fold-expression, which would naturally p=
roduce</div></div></div></div></div></blockquote><blockquote type=3D"cite" =
class=3D""><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><div clas=
s=3D"gmail_quote"><div class=3D""><br class=3D""></div><div class=3D"">&nbs=
p; expr$0, expr$1, ..., expr$N;</div><div class=3D""><br class=3D""><=
/div><div class=3D"">from</div><div class=3D""><br class=3D""></div><div cl=
ass=3D""> expr=E2=80=A6;</div></div></div></div></blockquote><div><br=
class=3D""></div><div>Per your previous message, it would be <font fa=
ce=3D"Courier" class=3D"">void(expr$0), void(expr$1), void(expr$N);</font>.=
That seems less natural than <font face=3D"Courier" class=3D"">{expr$0; ex=
pr$1; expr$N;}</font>. But the behavior is equivalent; it=E2=80=99s only a =
matter of standardese.</div></div><br class=3D""><div class=3D"">In other w=
ords, <font face=3D"Courier" class=3D"">...;</font> may as well n=
ot be a fold expression, either. Seems like a bit of work just to account f=
or <font face=3D"Courier" class=3D"">operator,</font> overloads and save on=
e character.</div><div class=3D""><br class=3D""></div></body></html>
<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--Apple-Mail=_2790FD9E-66A8-4F38-AF14-7F16470D5195--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 04 Feb 2016 21:57:00 -0800
Raw View
On sexta-feira, 5 de fevereiro de 2016 11:14:36 PST David Krauss wrote:
> Per your previous message, it would be void(expr$0), void(expr$1),
> void(expr$N);. That seems less natural than {expr$0; expr$1; expr$N;}. Bu=
t
> the behavior is equivalent; it=E2=80=99s only a matter of standardese.
Question: If the expressions returned a non-trivially-destructible object,=
=20
would they all have to be kept until all the expressions had been evaluated=
,=20
even cast to void?
Besides, I'm not sure the cast to void should be automatic.
If I had
void operator,(T, T);
template<typename Arg> T f(Arg);
template< typename ... Arg >
void foo(const Arg& ... a)
{
f(a), ...;
}
Which technically expands to:
f(a$0), f(a$1), ..., f(a$N);
Wouldn't the first two be expected to call that comma operator?
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 5 Feb 2016 14:22:22 +0800
Raw View
--Apple-Mail=_25F6F580-9C8B-4E8E-BA81-3E66B085FCBE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2016=E2=80=9302=E2=80=9305, at 1:57 PM, Thiago Macieira <thiago@maciei=
ra.org> wrote:
>=20
> On sexta-feira, 5 de fevereiro de 2016 11:14:36 PST David Krauss wrote:
>> Per your previous message, it would be void(expr$0), void(expr$1),
>> void(expr$N);. That seems less natural than {expr$0; expr$1; expr$N;}. B=
ut
>> the behavior is equivalent; it=E2=80=99s only a matter of standardese.
>=20
> Question: If the expressions returned a non-trivially-destructible object=
,=20
> would they all have to be kept until all the expressions had been evaluat=
ed,=20
> even cast to void?
Ah, good point. With ...;, you=E2=80=99d expect the objects to all live sim=
ultaneously. However, they=E2=80=99d be totally isolated from each other, s=
o it=E2=80=99s hard to see the benefit. The syntax ;... cosmetically looks =
like it will separate the full-expression lifetimes.
As it happens, my current preferred idiom generates full-expressions with s=
eparate lifetimes:
int ignore[] =3D { ( f(a), 0 ) ... }; // f(a$1) destroyed before f(a$2) eva=
luated.
> Besides, I'm not sure the cast to void should be automatic.
>=20
> If I had
>=20
> void operator,(T, T);
> template<typename Arg> T f(Arg);
>=20
> template< typename ... Arg >
> void foo(const Arg& ... a)
> {
> f(a), ...;
> }
>=20
> Which technically expands to:
>=20
> f(a$0), f(a$1), ..., f(a$N);
>=20
> Wouldn't the first two be expected to call that comma operator?
Certainly. We=E2=80=99re discussing potential differences between f(a)...; =
and f(a),...;. Omitting the comma would imply the casts to void.
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--Apple-Mail=_25F6F580-9C8B-4E8E-BA81-3E66B085FCBE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9302=
=E2=80=9305, at 1:57 PM, Thiago Macieira <<a href=3D"mailto:thiago@macie=
ira.org" class=3D"">thiago@macieira.org</a>> wrote:</div><br class=3D"Ap=
ple-interchange-newline"><div class=3D""><div class=3D"">On sexta-feira, 5 =
de fevereiro de 2016 11:14:36 PST David Krauss wrote:<br class=3D""><blockq=
uote type=3D"cite" class=3D"">Per your previous message, it would be void(e=
xpr$0), void(expr$1),<br class=3D"">void(expr$N);. That seems less natural =
than {expr$0; expr$1; expr$N;}. But<br class=3D"">the behavior is equivalen=
t; it=E2=80=99s only a matter of standardese.<br class=3D""></blockquote><b=
r class=3D"">Question: If the expressions returned a non-trivially-destruct=
ible object, <br class=3D"">would they all have to be kept until all the ex=
pressions had been evaluated, <br class=3D"">even cast to void?<br class=3D=
""></div></div></blockquote><div><br class=3D""></div><div>Ah, good point. =
With <font face=3D"Courier" class=3D"">...;</font>, you=E2=80=99d expect th=
e objects to all live simultaneously. However, they=E2=80=99d be totally is=
olated from each other, so it=E2=80=99s hard to see the benefit. The syntax=
<font face=3D"Courier" class=3D"">;...</font> cosmetically looks=
like it will separate the full-expression lifetimes.</div><div><br class=
=3D""></div><div>As it happens, my current preferred idiom generates full-e=
xpressions with separate lifetimes:</div><div><br class=3D""></div><div><fo=
nt face=3D"Courier" class=3D"">int ignore[] =3D { ( f(a), 0 ) ... }; // f(a=
$1) destroyed before f(a$2) evaluated.</font></div><div><br class=3D""></di=
v><blockquote type=3D"cite" class=3D""><div class=3D""><div class=3D"">Besi=
des, I'm not sure the cast to void should be automatic.<br class=3D""><br c=
lass=3D"">If I had<br class=3D""><br class=3D"">void operator,(T, T);<br cl=
ass=3D"">template<typename Arg> T f(Arg);<br class=3D""><br class=3D"=
">template< typename ... Arg ><br class=3D"">void foo(const Arg& =
.... a)<br class=3D"">{<br class=3D""><span class=3D"Apple-tab-span" style=
=3D"white-space:pre"> </span>f(a), ...;<br class=3D"">}<br class=3D""><br c=
lass=3D"">Which technically expands to:<br class=3D""><br class=3D""><span =
class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>f(a$0), f(a$1), =
...., f(a$N);<br class=3D""><br class=3D"">Wouldn't the first two be expecte=
d to call that comma operator?<br class=3D""></div></div></blockquote></div=
><br class=3D""><div class=3D"">Certainly. We=E2=80=99re discussing potenti=
al differences between <font face=3D"Courier" class=3D"">f(a)...;</font> an=
d <font face=3D"Courier" class=3D"">f(a),...;</font>. Omitting the comma wo=
uld imply the casts to <font face=3D"Courier" class=3D"">void</font>.</div>=
<div class=3D""><br class=3D""></div></body></html>
<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--Apple-Mail=_25F6F580-9C8B-4E8E-BA81-3E66B085FCBE--
.
Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Fri, 5 Feb 2016 09:45:42 -0800 (PST)
Raw View
------=_Part_314_1334591449.1454694342705
Content-Type: multipart/alternative;
boundary="----=_Part_315_801789124.1454694342706"
------=_Part_315_801789124.1454694342706
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=20
I was thinking more in terms of what would mean "folding operator() ?"=20
x(args) is an operator() 'binary relating' x and args ( I know it=C2=B4s no=
t a=20
binary operator )=20
1- Calls a single 'f' with each arg ( one at a time )=20
template<typename Foo, typename ...Args>
void go(Foo f, Args...a) {
f(args)...; // expands { f(a$0); f(a$1); ... ; f(a$n) }
}=20
2 - May be even possible the opposite: Call each f with a single arg
template<typename Arg, typename ...Foos>
void go(Arg a, Foos... f) {
f...(arg); // expands { f$0(a); f$1(a); ... ; f$n(a$n) }
}
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
------=_Part_315_801789124.1454694342706
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>=C2=A0</div><div>I was thinking more in terms of what=
would mean "folding operator() ?" x(args) is an operator() '=
binary relating' x and args ( I know it=C2=B4s not a binary operator )=
=C2=A0</div><div><br></div><div>1- Calls a single 'f' with each arg=
( one at a time )=C2=A0</div><div><br></div><div><div class=3D"prettyprint=
" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; bac=
kground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><font color=3D"#660066"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">template</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">Foo</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: #008;" class=3D"styled-by-prettify">typename</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">Args</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> go</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Foo</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</s=
pan><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: #606;" class=3D"styled-by-prettify">Args</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">a</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 f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">args</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">)...;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// expands { f(a$0); f(=
a$1); ... ; f(a$n) }</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an></font></div></code></div><div><br></div><div>2 - May be even possible t=
he opposite: Call each f with a single arg</div><div><br></div><div><div cl=
ass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wra=
p: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">template</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Arg</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">typename</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: #60=
6;" class=3D"styled-by-prettify">Foos</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> go</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Arg</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</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: #=
606;" class=3D"styled-by-prettify">Foos</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</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>=C2=A0 =
f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">arg</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// expands { f$0(a); f$1(a);=
... ; f$n(a$n) }</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an></div></code></div><br></div></div><div><br><br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_315_801789124.1454694342706--
------=_Part_314_1334591449.1454694342705--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Fri, 5 Feb 2016 11:01:52 -0800
Raw View
--001a1143ff34efad6a052b0a7b58
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thu, Feb 4, 2016 at 7:14 PM, David Krauss <potswa@gmail.com> wrote:
>
> On 2016=E2=80=9302=E2=80=9305, at 9:42 AM, Richard Smith <richard@metafoo=
..co.uk> wrote:
>
> A ... at the end of a statement closes lots of opportunities for future
> language extensions (such as removing the parens from fold-expressions, a=
s
> you [sic] suggest below). We should not do that lightly.
>
>
> Ah, I had assumed that the =E2=80=9Calternative formulation=E2=80=9D was =
equivalent to the
> status quo. Now I see that all fold expressions currently must be
> parenthesized.
>
> Given the extension for unparenthesized folds, merely omitting the comma
> in ,...; seems like a very narrow further extension.
>
> I thought I=E2=80=99d addressed the ambiguity, but indeed it=E2=80=99s su=
btler. A
> statement with an unexpanded pack may occur in a lambda, e.g.
>
> template< typename ... arg >
> void foo( arg const & ... a ) {
> bar( [&] {
> baz( a ); // Allowing ;... would require lookahead here:
> unexpanded pack is not a valid hint.
> ... || a( 42 );
> } ... );
> }
>
> It=E2=80=99s not clear that the opportunity is closed; this still looks l=
ike just
> one extra token of lookahead. (Still, that=E2=80=99s a strike against.) I=
s there
> anything more to it?
>
Try + (or any operator that's both unary and binary) instead of ||.
> Also, semicolon is not a binary operator, so it doesn't make sense to fol=
d
> over it.
>
>
> ;... certainly wouldn=E2=80=99t be a fold expression. Its advantage is th=
at the
> pattern explicitly appears before the ellipsis.
>
Only if you think it produces a sequence of semicolon-terminated
expression-statements, which is obviously not what we want:
if (blah)
foo; ... // oops?
Injecting braces also seems much more magical than a normal pack expansion.
What I think we want is a construct that expands to a single
expression-statement, so the natural delimiter is , not ;.
> It makes more sense (I think) to think of this as a normal pack expansion=
,
> not a fold-expression, which would naturally produce
>
>
> expr$0, expr$1, ..., expr$N;
>
> from
>
> expr=E2=80=A6;
>
>
> Per your previous message, it would be void(expr$0), void(expr$1),
> void(expr$N);. That seems less natural than {expr$0; expr$1; expr$N;}.
> But the behavior is equivalent; it=E2=80=99s only a matter of standardese=
..
>
> In other words, ...; may as well not be a fold expression, either. Seems
> like a bit of work just to account for operator, overloads and save one
> character.
>
I agree, this should not be a fold-expression, just a normal pack expansion
producing a comma-separated list (but forced to use the built-in operator,
somehow).
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--001a1143ff34efad6a052b0a7b58
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 T=
hu, Feb 4, 2016 at 7:14 PM, David Krauss <span dir=3D"ltr"><<a href=3D"m=
ailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>></span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"=
><br><div><blockquote type=3D"cite"><div>On 2016=E2=80=9302=E2=80=9305, at =
9:42 AM, Richard Smith <<a href=3D"mailto:richard@metafoo.co.uk" target=
=3D"_blank">richard@metafoo.co.uk</a>> wrote:</div><br><div><div dir=3D"=
ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div>A ... at th=
e end of a statement closes lots of opportunities for future language exten=
sions (such as removing the parens from fold-expressions, as you [sic] sugg=
est below). We should not do that lightly. </div></div></div></div></div></=
blockquote><div><br></div><div>Ah, I had assumed that the =E2=80=9Calternat=
ive formulation=E2=80=9D was equivalent to the status quo. Now I see that a=
ll fold expressions currently must be parenthesized.</div><div><br></div><d=
iv>Given the extension for unparenthesized folds, merely omitting the comma=
in <font face=3D"Courier">,...;</font> seems like a very narrow further ex=
tension.</div><div><br></div><div>I thought I=E2=80=99d addressed the ambig=
uity, but indeed it=E2=80=99s subtler. A statement with an unexpanded pack =
may occur in a lambda, e.g.</div><div><br></div><div><font face=3D"Courier"=
>template< typename ... arg ></font></div><div><font face=3D"Courier"=
>void foo( arg const & ... a ) {</font></div><div><font face=3D"Courier=
">=C2=A0 =C2=A0 bar( [&] {</font></div><div><font face=3D"Courier">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 baz( a ); // Allowing ;... would require lookahead=
here: unexpanded pack is not a valid hint.</font></div><div><font face=3D"=
Courier">=C2=A0 =C2=A0 =C2=A0 =C2=A0 ... || a( 42 );</font></div><div><font=
face=3D"Courier">=C2=A0 =C2=A0 } ... );</font></div><div><font face=3D"Cou=
rier">}</font></div><div><br></div><div>It=E2=80=99s not clear that the opp=
ortunity is closed; this still looks like just one extra token of lookahead=
.. (Still, that=E2=80=99s a strike against.) Is there anything more to it?</=
div></div></div></blockquote><div><br></div><div>Try + (or any operator tha=
t's both unary and binary) instead of ||.<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div style=3D"word-wrap:break-word"><div><span class=3D""><block=
quote type=3D"cite"><div><div dir=3D"ltr"><div class=3D"gmail_extra"><div c=
lass=3D"gmail_quote"><div>Also, semicolon is not a binary operator, so it d=
oesn't make sense to fold over it. </div></div></div></div></div></bloc=
kquote><div><br></div></span><div><font face=3D"Courier">;...</font>=C2=A0c=
ertainly wouldn=E2=80=99t be a fold expression. Its advantage is that the p=
attern explicitly appears before the ellipsis.</div></div></div></blockquot=
e><div><br></div><div>Only if you think it produces a sequence of semicolon=
-terminated expression-statements, which is obviously not what we want:<br>=
</div><div><br></div><div>=C2=A0 if (blah)</div><div>=C2=A0 =C2=A0 foo; ...=
// oops?</div><div><br></div><div>Injecting braces also seems much more ma=
gical than a normal pack expansion. What I think we want is a construct tha=
t expands to a single expression-statement, so the natural delimiter is , n=
ot ;.</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-wor=
d"><div><span class=3D""><blockquote type=3D"cite"><div><div dir=3D"ltr"><d=
iv class=3D"gmail_extra"><div class=3D"gmail_quote"><div>It makes more sens=
e (I think) to think of this as a normal pack expansion, not a fold-express=
ion, which would naturally produce</div></div></div></div></div></blockquot=
e></span><blockquote type=3D"cite"><div dir=3D"ltr"><div class=3D"gmail_ext=
ra"><div class=3D"gmail_quote"><span class=3D""><div><br></div><div>=C2=A0 =
=C2=A0expr$0, expr$1, ..., expr$N;</div><div><br></div><div>from</div><div>=
<br></div></span><div>=C2=A0 expr=E2=80=A6;</div></div></div></div></blockq=
uote><div><br></div><div>Per your previous message, it would be=C2=A0<font =
face=3D"Courier">void(expr$0), void(expr$1), void(expr$N);</font>. That see=
ms less natural than <font face=3D"Courier">{expr$0; expr$1; expr$N;}</font=
>. But the behavior is equivalent; it=E2=80=99s only a matter of standardes=
e.</div></div><br><div>In other words,=C2=A0<font face=3D"Courier">...;</fo=
nt>=C2=A0may as well not be a fold expression, either. Seems like a bit of =
work just to account for <font face=3D"Courier">operator,</font> overloads =
and save one character.</div></div></blockquote><div><br></div><div>I agree=
, this should not be a fold-expression, just a normal pack expansion produc=
ing a comma-separated list (but forced to use the built-in operator, someho=
w).=C2=A0</div></div></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a1143ff34efad6a052b0a7b58--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Fri, 5 Feb 2016 11:04:18 -0800
Raw View
--001a11414f48a62f9d052b0a8439
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thu, Feb 4, 2016 at 10:22 PM, David Krauss <potswa@gmail.com> wrote:
>
> On 2016=E2=80=9302=E2=80=9305, at 1:57 PM, Thiago Macieira <thiago@maciei=
ra.org> wrote:
>
> On sexta-feira, 5 de fevereiro de 2016 11:14:36 PST David Krauss wrote:
>
> Per your previous message, it would be void(expr$0), void(expr$1),
> void(expr$N);. That seems less natural than {expr$0; expr$1; expr$N;}. Bu=
t
> the behavior is equivalent; it=E2=80=99s only a matter of standardese.
>
>
> Question: If the expressions returned a non-trivially-destructible object=
,
> would they all have to be kept until all the expressions had been
> evaluated,
> even cast to void?
>
>
> Ah, good point. With ...;, you=E2=80=99d expect the objects to all live
> simultaneously. However, they=E2=80=99d be totally isolated from each oth=
er, so
> it=E2=80=99s hard to see the benefit. The syntax ;... cosmetically looks =
like it
> will separate the full-expression lifetimes.
>
> As it happens, my current preferred idiom generates full-expressions with
> separate lifetimes:
>
Not for long. Under core issue 1343, we're intending to make the entire
initializer for your 'ignore' variable a single full-expression.
> int ignore[] =3D { ( f(a), 0 ) ... }; // f(a$1) destroyed before f(a$2)
> evaluated.
>
> Besides, I'm not sure the cast to void should be automatic.
>
> If I had
>
> void operator,(T, T);
> template<typename Arg> T f(Arg);
>
> template< typename ... Arg >
> void foo(const Arg& ... a)
> {
> f(a), ...;
> }
>
> Which technically expands to:
>
> f(a$0), f(a$1), ..., f(a$N);
>
> Wouldn't the first two be expected to call that comma operator?
>
>
> Certainly. We=E2=80=99re discussing potential differences between f(a)...=
; and
> f(a),...;. Omitting the comma would imply the casts to void.
>
> --
>
> ---
> 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
> https://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--001a11414f48a62f9d052b0a8439
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 T=
hu, Feb 4, 2016 at 10:22 PM, David Krauss <span dir=3D"ltr"><<a href=3D"=
mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>></span> =
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word=
"><br><div><span class=3D""><blockquote type=3D"cite"><div>On 2016=E2=80=93=
02=E2=80=9305, at 1:57 PM, Thiago Macieira <<a href=3D"mailto:thiago@mac=
ieira.org" target=3D"_blank">thiago@macieira.org</a>> wrote:</div><br><d=
iv><div>On sexta-feira, 5 de fevereiro de 2016 11:14:36 PST David Krauss wr=
ote:<br><blockquote type=3D"cite">Per your previous message, it would be vo=
id(expr$0), void(expr$1),<br>void(expr$N);. That seems less natural than {e=
xpr$0; expr$1; expr$N;}. But<br>the behavior is equivalent; it=E2=80=99s on=
ly a matter of standardese.<br></blockquote><br>Question: If the expression=
s returned a non-trivially-destructible object, <br>would they all have to =
be kept until all the expressions had been evaluated, <br>even cast to void=
?<br></div></div></blockquote><div><br></div></span><div>Ah, good point. Wi=
th <font face=3D"Courier">...;</font>, you=E2=80=99d expect the objects to =
all live simultaneously. However, they=E2=80=99d be totally isolated from e=
ach other, so it=E2=80=99s hard to see the benefit. The syntax=C2=A0<font f=
ace=3D"Courier">;...</font>=C2=A0cosmetically looks like it will separate t=
he full-expression lifetimes.</div><div><br></div><div>As it happens, my cu=
rrent preferred idiom generates full-expressions with separate lifetimes:</=
div></div></div></blockquote><div><br></div><div>Not for long. Under core i=
ssue 1343, we're intending to make the entire initializer for your '=
;ignore' variable a single full-expression.</div><div>=C2=A0</div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><div><div><fo=
nt face=3D"Courier">int ignore[] =3D { ( f(a), 0 ) ... }; // f(a$1) destroy=
ed before f(a$2) evaluated.</font></div><span class=3D""><div><br></div><bl=
ockquote type=3D"cite"><div><div>Besides, I'm not sure the cast to void=
should be automatic.<br><br>If I had<br><br>void operator,(T, T);<br>templ=
ate<typename Arg> T f(Arg);<br><br>template< typename ... Arg >=
<br>void foo(const Arg& ... a)<br>{<br><span style=3D"white-space:pre-w=
rap"> </span>f(a), ...;<br>}<br><br>Which technically expands to:<br><br><s=
pan style=3D"white-space:pre-wrap"> </span>f(a$0), f(a$1), ..., f(a$N);<br>=
<br>Wouldn't the first two be expected to call that comma operator?<br>=
</div></div></blockquote></span></div><br><div>Certainly. We=E2=80=99re dis=
cussing potential differences between <font face=3D"Courier">f(a)...;</font=
> and <font face=3D"Courier">f(a),...;</font>. Omitting the comma would imp=
ly the casts to <font face=3D"Courier">void</font>.</div><div><br></div></d=
iv><div class=3D"HOEnZb"><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/" target=3D"_blank">https://groups.google.com/a/isocpp.org/g=
roup/std-proposals/</a>.<br>
</div></div></blockquote></div><br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a11414f48a62f9d052b0a8439--
.