Topic: [std-proposals] Re: Tersest Lambdas - N3560++ (Propo


Author: Scott Prager <splinterofchaos@gmail.com>
Date: Fri, 12 Dec 2014 17:57:45 -0800 (PST)
Raw View
------=_Part_1128_1638716374.1418435865593
Content-Type: multipart/alternative;
 boundary="----=_Part_1129_428325043.1418435865593"

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



On Friday, December 12, 2014 11:03:23 AM UTC-5, Kizza George Mbidde wrote:
=20

> =20
> Section 2.2 of *=E2=80=9CN3560 - Proposal for Assorted Extensions to Lamb=
da=20
> Expressions=E2=80=9D* already suggested a terse syntax for C++ lambdas;
> =20
> [&](const auto& e) root.execute(e)
>

=20

> =20
> Why not introduce a syntax similar in spirit to the Eiffel syntax? Why do=
=20
> we need to enforce that *(const auto& e)* section of code? In light of=20
> the Eiffel syntax, this would be the C++ equivalent;
> =20
> [&] root.execute(?)
>


Unfortunately, I don't think the terse syntax ([&](auto x) x) made the cut.=
=20
I'd appreciate it if anyone knew why. But for your proposal, consider this:

    std::accumulate(nums.begin(), nums.end(), [&] (?) + (?));  // can there=
=20
be two?


    std::for_each(fns.begin(), fns.end(), [] (?)(1));  // can I call a (?)?


    std::for_each(xs.begin(), xs.end(), // can I have multiple statements?
        []{ std::cout << (?) << std::endl;
            (?)++; }
    );


--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

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

<div dir=3D"ltr"><br><br>On Friday, December 12, 2014 11:03:23 AM UTC-5, Ki=
zza George Mbidde wrote:<div>&nbsp;</div><blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr"><div><font face=3D"georgia,serif"><font size=3D=
"4">&nbsp;<br>Section 2.2 of <strong><em>=E2=80=9CN3560 - Proposal for Asso=
rted Extensions to Lambda Expressions=E2=80=9D</em></strong> already sugges=
ted a terse syntax for C++ lambdas;<br>&nbsp;<br></font><font size=3D"4"><f=
ont color=3D"#0000ff">[&amp;](const auto&amp; e) root.execute(e)<br></font>=
</font></font></div></div></blockquote><div><br></div><div>&nbsp;</div><blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><font face=
=3D"georgia,serif"><font size=3D"4"><font color=3D"#0000ff"></font>&nbsp;<b=
r>Why not introduce a syntax similar in spirit to the Eiffel syntax? Why do=
 we need to enforce that <strong><em>(const auto&amp; e)</em></strong> sect=
ion of code? In light of the Eiffel syntax, this would be the C++ equivalen=
t;<br>&nbsp;<br></font><font size=3D"4"><font color=3D"#0000ff">[&amp;] roo=
t.execute(?)<br></font></font></font></div></div></blockquote><div><br></di=
v><div><br></div><div>Unfortunately, I don't think the terse syntax ([&amp;=
](auto x) x) made the cut. I'd appreciate it if anyone knew why. But for yo=
ur proposal, consider this:</div><div><br></div><div class=3D"prettyprint" =
style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backg=
round-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
&nbsp; &nbsp; std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
ccumulate</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">nums</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">begin</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(),</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> nums</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">end</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(),</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[&amp;]</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(?)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">+</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(?));</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> &nbsp;</span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// can there be two?</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp; std</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">for_each</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">fns</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(),</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> fns</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">.</span><span style=3D"color: #008;" class=3D"styled-by-prettify">end=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(),</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[]</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(?)(</span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">));</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> &nbsp;</span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// can I call a (?)?</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br><br>&nbsp; &nbsp; std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">for_each</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">xs</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">.</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
begin</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(),</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> xs</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">end</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(),</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// can I have multiple statements?</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &n=
bsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[]{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(?)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(?)++;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;=
 &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">);=
</span></div></code></div><div><br></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&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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1129_428325043.1418435865593--
------=_Part_1128_1638716374.1418435865593--

.


Author: Kizza George Mbidde <kizza.mbidde@gmail.com>
Date: Sat, 13 Dec 2014 13:52:05 -0800 (PST)
Raw View
------=_Part_521_2147039787.1418507525840
Content-Type: multipart/alternative;
 boundary="----=_Part_522_1129979568.1418507525840"

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

Thanks Scott. The last of the three examples you provided (coupled with=20
Vicente's feedback) has got me reevaluating the proposal.

On Saturday, December 13, 2014 4:57:45 AM UTC+3, Scott Prager wrote:
>
>
>
> On Friday, December 12, 2014 11:03:23 AM UTC-5, Kizza George Mbidde wrote=
:
> =20
>
>> =20
>> Section 2.2 of *=E2=80=9CN3560 - Proposal for Assorted Extensions to Lam=
bda=20
>> Expressions=E2=80=9D* already suggested a terse syntax for C++ lambdas;
>> =20
>> [&](const auto& e) root.execute(e)
>>
>
> =20
>
>> =20
>> Why not introduce a syntax similar in spirit to the Eiffel syntax? Why d=
o=20
>> we need to enforce that *(const auto& e)* section of code? In light of=
=20
>> the Eiffel syntax, this would be the C++ equivalent;
>> =20
>> [&] root.execute(?)
>>
>
>
> Unfortunately, I don't think the terse syntax ([&](auto x) x) made the=20
> cut. I'd appreciate it if anyone knew why. But for your proposal, conside=
r=20
> this:
>
>     std::accumulate(nums.begin(), nums.end(), [&] (?) + (?));  // can=20
> there be two?
>
>
>     std::for_each(fns.begin(), fns.end(), [] (?)(1));  // can I call a=20
> (?)?
>
>
>     std::for_each(xs.begin(), xs.end(), // can I have multiple statements=
?
>         []{ std::cout << (?) << std::endl;
>             (?)++; }
>     );
>
>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

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

<div dir=3D"ltr"><font size=3D"4"><span style=3D"font-family: georgia,serif=
;">Thanks Scott. The last of the three examples you provided (coupled with =
Vicente's feedback) has got me reevaluating the proposal.<br></span></font>=
<br>On Saturday, December 13, 2014 4:57:45 AM UTC+3, Scott Prager wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><br>On Frida=
y, December 12, 2014 11:03:23 AM UTC-5, Kizza George Mbidde wrote:<div>&nbs=
p;</div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><font=
 face=3D"georgia,serif"><font size=3D"4">&nbsp;<br>Section 2.2 of <b><i>=E2=
=80=9CN3560 - Proposal for Assorted Extensions to Lambda Expressions=E2=80=
=9D</i></b> already suggested a terse syntax for C++ lambdas;<br>&nbsp;<br>=
</font><font size=3D"4"><font color=3D"#0000ff">[&amp;](const auto&amp; e) =
root.execute(e)<br></font></font></font></div></div></blockquote><div><br><=
/div><div>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin:0;m=
argin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div><font face=3D"georgia,serif"><font size=3D"4"><font color=3D"#0000=
ff"></font>&nbsp;<br>Why not introduce a syntax similar in spirit to the Ei=
ffel syntax? Why do we need to enforce that <b><i>(const auto&amp; e)</i></=
b> section of code? In light of the Eiffel syntax, this would be the C++ eq=
uivalent;<br>&nbsp;<br></font><font size=3D"4"><font color=3D"#0000ff">[&am=
p;] root.execute(?)<br></font></font></font></div></div></blockquote><div><=
br></div><div><br></div><div>Unfortunately, I don't think the terse syntax =
([&amp;](auto x) x) made the cut. I'd appreciate it if anyone knew why. But=
 for your proposal, consider this:</div><div><br></div><div style=3D"border=
:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,2=
50,250)"><code><div><span style=3D"color:#000">&nbsp; &nbsp; std</span><spa=
n style=3D"color:#660">::</span><span style=3D"color:#000">accumulate</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">nums</span><=
span style=3D"color:#660">.</span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(),</span><span style=3D"color:#000"> nums</span><=
span style=3D"color:#660">.</span><span style=3D"color:#008">end</span><spa=
n style=3D"color:#660">(),</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#660">[&amp;]</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">(?)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">+</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">(?));</span><span style=3D"color:#000"> &nbsp;</span><span sty=
le=3D"color:#800">// can there be two?</span><span style=3D"color:#000"><br=
><br><br>&nbsp; &nbsp; std</span><span style=3D"color:#660">::</span><span =
style=3D"color:#000">for_each</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#000">fns</span><span style=3D"color:#660">.</span><span s=
tyle=3D"color:#008">begin</span><span style=3D"color:#660">(),</span><span =
style=3D"color:#000"> fns</span><span style=3D"color:#660">.</span><span st=
yle=3D"color:#008">end</span><span style=3D"color:#660">(),</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">[]</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">(?)(</span><span style=
=3D"color:#066">1</span><span style=3D"color:#660">));</span><span style=3D=
"color:#000"> &nbsp;</span><span style=3D"color:#800">// can I call a (?)?<=
/span><span style=3D"color:#000"><br><br><br>&nbsp; &nbsp; std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">for_each</span><sp=
an style=3D"color:#660">(</span><span style=3D"color:#000">xs</span><span s=
tyle=3D"color:#660">.</span><span style=3D"color:#008">begin</span><span st=
yle=3D"color:#660">(),</span><span style=3D"color:#000"> xs</span><span sty=
le=3D"color:#660">.</span><span style=3D"color:#008">end</span><span style=
=3D"color:#660">(),</span><span style=3D"color:#000"> </span><span style=3D=
"color:#800">// can I have multiple statements?</span><span style=3D"color:=
#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </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">cout </span><span style=3D"color:#660">&lt=
;&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">(=
?)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&lt;=
&lt;</span><span style=3D"color:#000"> std</span><span style=3D"color:#660"=
>::</span><span style=3D"color:#000">endl</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp;</span><span style=3D"color:#000"> </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>&nbsp; &nbsp; </span><span style=3D"c=
olor:#660">);</span></div></code></div><div><br></div><div><br></div></div>=
</blockquote></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_522_1129979568.1418507525840--
------=_Part_521_2147039787.1418507525840--

.