Topic: N3560 lambda body expression ambiguity
Author: Marcin <inkwizytoryankes@gmail.com>
Date: Sun, 7 Apr 2013 03:13:49 -0700 (PDT)
Raw View
------=_Part_3426_33142019.1365329629165
Content-Type: text/plain; charset=ISO-8859-1
New proposition allow use statements as lambda body. But if is allowed to
skip "lambda-declarator" we can have new ambiguity (mostly for programmers):
auto a1 = [](int)2.5; // int(*)() or double(*)(int)?
I propose adding new syntax for this:
auto a2 = [](int) = 2.5; // double(*)(int)
auto a3 = [] = (int)2.5; // int(*)()
this will too fix problem with declaring return type:
auto a4 = [](auto a) -> int* = (a); // without '=' we have [](auto a) ->
int*(a) that is example of ambiguity in N3560
this new syntax will make handling comma intuitive:
int a;
foo(a = 5, 5); // foo((a = 5), 5);
bar([] = 5, 5); // bar(([] = 5), 5);
int b = a = 5, c; // int b = (a = 5), c;
Func f = [=](int)->int = a, h; // Func f = ([=]->int = a), h;
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
------=_Part_3426_33142019.1365329629165
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>New proposition allow use statements as lambda body. But if is allowed =
to skip "lambda-declarator" we can have new ambiguity (mostly for programm=
ers):<br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width=
: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a1 </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</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:=
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)</span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">2.5</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// i=
nt(*)() or double(*)(int)?</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span></div></code></div><br>I propose adding new synt=
ax for this:<br><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a=
2 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">[](</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">2.5</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">// double(*)(int)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> a3 </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">[]</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</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: #008;" class=3D"styled-by-prettify">int</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #066;" class=3D"styled-by-prettify">2.5</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// int(*)()</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span></div></code></div><br>this will too fix prob=
lem with declaring return type:<br><div class=3D"prettyprint" style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> a4 </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[](<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> a</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"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</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: #660;" class=3D"styled-by-prettify">=3D</sp=
an><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">a</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">// without '=3D' we have [](auto a) -> int*(a) that is =
example of ambiguity in N3560</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span></div></code></div><br>this new syntax will m=
ake handling comma intuitive:<br><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">a </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">5</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: #066;" class=3D"styled-by=
-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// foo((a =3D 5=
), 5);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">([]</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">5</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: #066;" class=3D"styled-by=
-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// bar(([] =3D =
5), 5);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> c</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: #800;" class=3D"styled-by-prettify">// int b =3D (a =
=3D 5), c;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">[=3D](</span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)-></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> h</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: #8=
00;" class=3D"styled-by-prettify">// Func f =3D ([=3D]->int =3D a), h;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
/div></code></div><br><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_3426_33142019.1365329629165--
.
Author: Faisal Vali <faisalv@gmail.com>
Date: Sun, 7 Apr 2013 07:53:12 -0500
Raw View
--f46d0447f3829a30f204d9c4cdbf
Content-Type: text/plain; charset=ISO-8859-1
On Sun, Apr 7, 2013 at 5:13 AM, Marcin <inkwizytoryankes@gmail.com> wrote:
>
> New proposition allow use statements as lambda body. But if is allowed to
> skip "lambda-declarator" we can have new ambiguity (mostly for programmers):
> auto a1 = [](int)2.5; // int(*)() or double(*)(int)?
>
>
Per the grammar, this would have to be double (*)(int).
> I propose adding new syntax for this:
> auto a2 = [](int) = 2.5; // double(*)(int)
> auto a3 = [] = (int)2.5; // int(*)()
>
> this will too fix problem with declaring return type:
> auto a4 = [](auto a) -> int* = (a); // without '=' we have [](auto a) ->
> int*(a) that is example of ambiguity in N3560
>
> this new syntax will make handling comma intuitive:
> int a;
> foo(a = 5, 5); // foo((a = 5), 5);
> bar([] = 5, 5); // bar(([] = 5), 5);
>
> int b = a = 5, c; // int b = (a = 5), c;
> Func f = [=](int)->int = a, h; // Func f = ([=]->int = a), h;
>
>
>
Someone else (Ivan Sorokin) suggested requiring a colon to separate the
single-lambda-body-expression from its declarator. FWIW, I do like the
suggestion, and prefer the colon (which Dave Abrahams reminded us has
precedence in python) to the assignment operator (since we are not really
assigning a value but describing how the result will be computed whenever
the lambda is invoked).
So for e.g.
auto a2 = [](int) : 2.5;
auto a3 = [] : (int) 2.5;
auto a4 = [](auto a) -> int* : (a);
bar([] : 5, 5);
Func f = [=](int)->int : a, h;
What do the rest of you think?
thanks!
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
--f46d0447f3829a30f204d9c4cdbf
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sun, Apr 7, 2013 at 5:13 AM, Marcin <span dir=3D"ltr"><<a href=3D=
"mailto:inkwizytoryankes@gmail.com" target=3D"_blank">inkwizytoryankes@gmai=
l.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><br>New proposition allow use statements as =
lambda body. But if is allowed to skip "lambda-declarator" we ca=
n have new ambiguity (mostly for programmers):<br>
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">auto</span><span style> a1 </span><span style=3D"co=
lor:#660">=3D</span><span style> </span><span style=3D"color:#660">[](</spa=
n><span style=3D"color:#008">int</span><span style=3D"color:#660">)</span><=
span style=3D"color:#066">2.5</span><span style=3D"color:#660">;</span><spa=
n style> </span><span style=3D"color:#800">// int(*)() or double(*)(int)?</=
span><span style><br>
</span></div></code></div><br></blockquote><div><br><br></div><div>Per the =
grammar, this would have to be double (*)(int).<br></div><div><br>=A0</div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
I propose adding new syntax for this:<br><div style=3D"background-color:rgb=
(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width=
:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">auto</span=
><span style> a2 </span><span style=3D"color:#660">=3D</span><span style> <=
/span><span style=3D"color:#660">[](</span><span style=3D"color:#008">int</=
span><span style=3D"color:#660">)</span><span style> </span><span style=3D"=
color:#660">=3D</span><span style> </span><span style=3D"color:#066">2.5</s=
pan><span style=3D"color:#660">;</span><span style> </span><span style=3D"c=
olor:#800">// double(*)(int)</span><span style><br>
</span><span style=3D"color:#008">auto</span><span style> a3 </span><span s=
tyle=3D"color:#660">=3D</span><span style> </span><span style=3D"color:#660=
">[]</span><span style> </span><span style=3D"color:#660">=3D</span><span s=
tyle> </span><span style=3D"color:#660">(</span><span style=3D"color:#008">=
int</span><span style=3D"color:#660">)</span><span style=3D"color:#066">2.5=
</span><span style=3D"color:#660">;</span><span style> </span><span style=
=3D"color:#800">// int(*)()</span><span style><br>
</span></div></code></div><br>this will too fix problem with declaring retu=
rn type:<br><div style=3D"background-color:rgb(250,250,250);border-color:rg=
b(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><span style=3D"color:#008">auto</span><span style> a4 </span><sp=
an style=3D"color:#660">=3D</span><span style> </span><span style=3D"color:=
#660">[](</span><span style=3D"color:#008">auto</span><span style> a</span>=
<span style=3D"color:#660">)</span><span style> </span><span style=3D"color=
:#660">-></span><span style> </span><span style=3D"color:#008">int</span=
><span style=3D"color:#660">*</span><span style> </span><span style=3D"colo=
r:#660">=3D</span><span style> </span><span style=3D"color:#660">(</span><s=
pan style>a</span><span style=3D"color:#660">);</span><span style> </span><=
span style=3D"color:#800">// without '=3D' we have [](auto a) ->=
int*(a) that is example of ambiguity in N3560</span><span style><br>
</span></div></code></div><br>this new syntax will make handling comma intu=
itive:<br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><cod=
e><div>
<span style=3D"color:#008">int</span><span style> a</span><span style=3D"co=
lor:#660">;</span><span style><br>foo</span><span style=3D"color:#660">(</s=
pan><span style>a </span><span style=3D"color:#660">=3D</span><span style> =
</span><span style=3D"color:#066">5</span><span style=3D"color:#660">,</spa=
n><span style> </span><span style=3D"color:#066">5</span><span style=3D"col=
or:#660">);</span><span style> </span><span style=3D"color:#800">// foo((a =
=3D 5), 5);</span><span style><br>
bar</span><span style=3D"color:#660">([]</span><span style> </span><span st=
yle=3D"color:#660">=3D</span><span style> </span><span style=3D"color:#066"=
>5</span><span style=3D"color:#660">,</span><span style> </span><span style=
=3D"color:#066">5</span><span style=3D"color:#660">);</span><span style> </=
span><span style=3D"color:#800">// bar(([] =3D 5), 5);</span><span style><b=
r>
<br></span><span style=3D"color:#008">int</span><span style> b </span><span=
style=3D"color:#660">=3D</span><span style> a </span><span style=3D"color:=
#660">=3D</span><span style> </span><span style=3D"color:#066">5</span><spa=
n style=3D"color:#660">,</span><span style> c</span><span style=3D"color:#6=
60">;</span><span style> </span><span style=3D"color:#800">// int b =3D (a =
=3D 5), c;</span><span style><br>
</span><span style=3D"color:#606">Func</span><span style> f </span><span st=
yle=3D"color:#660">=3D</span><span style> </span><span style=3D"color:#660"=
>[=3D](</span><span style=3D"color:#008">int</span><span style=3D"color:#66=
0">)-></span><span style=3D"color:#008">int</span><span style> </span><s=
pan style=3D"color:#660">=3D</span><span style> a</span><span style=3D"colo=
r:#660">,</span><span style> h</span><span style=3D"color:#660">;</span><sp=
an style> </span><span style=3D"color:#800">// Func f =3D ([=3D]->int =
=3D a), h;</span><span class=3D"HOEnZb"><font color=3D"#888888"><span style=
><br>
</span></font></span></div></code></div><span class=3D"HOEnZb"><font color=
=3D"#888888"><br><br></font></span></blockquote><div><br></div><div><br></d=
iv><div>Someone else (Ivan Sorokin) suggested requiring a colon to separate=
the single-lambda-body-expression from its declarator. FWIW, I do like the=
suggestion, and prefer the colon (which Dave Abrahams reminded us has prec=
edence in python) to the assignment operator (since we are not really assig=
ning a value but describing how the result will be computed whenever the la=
mbda is invoked).<br>
</div><div><br></div><div>So for e.g.<br><br></div><div>auto a2 =3D [](int)=
: 2.5;<br></div><div>auto a3 =3D [] : (int) 2.5;<br></div><div>auto a4 =3D=
[](auto a) -> int* : (a);<br></div><div>bar([] : 5, 5);<br></div><div>F=
unc f =3D [=3D](int)->int : a, h;<br>
<br></div><div>What do the rest of you think?<br><br></div><div>thanks!<br>=
<br></div><div><br><br></div><br></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--f46d0447f3829a30f204d9c4cdbf--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 7 Apr 2013 06:36:48 -0700 (PDT)
Raw View
------=_Part_2020_22650035.1365341808926
Content-Type: text/plain; charset=ISO-8859-1
On Sunday, April 7, 2013 5:53:12 AM UTC-7, faisalv wrote:
>
>
>
> On Sun, Apr 7, 2013 at 5:13 AM, Marcin <inkwizyt...@gmail.com<javascript:>
> > wrote:
>
>>
>> New proposition allow use statements as lambda body. But if is allowed to
>> skip "lambda-declarator" we can have new ambiguity (mostly for programmers):
>> auto a1 = [](int)2.5; // int(*)() or double(*)(int)?
>>
>>
>
> Per the grammar, this would have to be double (*)(int).
>
>
>
>> I propose adding new syntax for this:
>> auto a2 = [](int) = 2.5; // double(*)(int)
>> auto a3 = [] = (int)2.5; // int(*)()
>>
>> this will too fix problem with declaring return type:
>> auto a4 = [](auto a) -> int* = (a); // without '=' we have [](auto a) ->
>> int*(a) that is example of ambiguity in N3560
>>
>> this new syntax will make handling comma intuitive:
>> int a;
>> foo(a = 5, 5); // foo((a = 5), 5);
>> bar([] = 5, 5); // bar(([] = 5), 5);
>>
>> int b = a = 5, c; // int b = (a = 5), c;
>> Func f = [=](int)->int = a, h; // Func f = ([=]->int = a), h;
>>
>>
>>
>
> Someone else (Ivan Sorokin) suggested requiring a colon to separate the
> single-lambda-body-expression from its declarator. FWIW, I do like the
> suggestion, and prefer the colon (which Dave Abrahams reminded us has
> precedence in python) to the assignment operator (since we are not really
> assigning a value but describing how the result will be computed whenever
> the lambda is invoked).
>
> So for e.g.
>
> auto a2 = [](int) : 2.5;
> auto a3 = [] : (int) 2.5;
> auto a4 = [](auto a) -> int* : (a);
> bar([] : 5, 5);
> Func f = [=](int)->int : a, h;
>
> What do the rest of you think?
>
> thanks!
>
I'd say that it's better solved by requiring that you use a parameter list.
Even for no parameters. Thus `[]()` is the most minimalistic lambda inducer
possible. It's only one character more than `[]:`, and it would be clear
from the rules what it means. Therefore, `[](int)2.5` would have a very
clear meaning.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
------=_Part_2020_22650035.1365341808926
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><br>On Sunday, April 7, 2013 5:53:12 AM UTC-7, faisalv wrote:<blockquot=
e 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><div><br><div class=
=3D"gmail_quote">On Sun, Apr 7, 2013 at 5:13 AM, Marcin <span dir=3D"ltr">&=
lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"pXXCL=
xLVdigJ">inkwizyt...@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><br>New proposition allow use statements as =
lambda body. But if is allowed to skip "lambda-declarator" we can have new=
ambiguity (mostly for programmers):<br>
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">auto</span><span> a1 </span><span style=3D"color:#6=
60">=3D</span><span> </span><span style=3D"color:#660">[](</span><span styl=
e=3D"color:#008">int</span><span style=3D"color:#660">)</span><span style=
=3D"color:#066">2.5</span><span style=3D"color:#660">;</span><span> </span>=
<span style=3D"color:#800">// int(*)() or double(*)(int)?</span><span><br>
</span></div></code></div><br></blockquote><div><br><br></div><div>Per the =
grammar, this would have to be double (*)(int).<br></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">
I propose adding new syntax for this:<br><div style=3D"background-color:rgb=
(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width=
:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">auto</span=
><span> a2 </span><span style=3D"color:#660">=3D</span><span> </span><span =
style=3D"color:#660">[](</span><span style=3D"color:#008">int</span><span s=
tyle=3D"color:#660">)</span><span> </span><span style=3D"color:#660">=3D</s=
pan><span> </span><span style=3D"color:#066">2.5</span><span style=3D"color=
:#660">;</span><span> </span><span style=3D"color:#800">// double(*)(int)</=
span><span><br>
</span><span style=3D"color:#008">auto</span><span> a3 </span><span style=
=3D"color:#660">=3D</span><span> </span><span style=3D"color:#660">[]</span=
><span> </span><span style=3D"color:#660">=3D</span><span> </span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#008">int</span><span style=
=3D"color:#660">)</span><span style=3D"color:#066">2.5</span><span style=3D=
"color:#660">;</span><span> </span><span style=3D"color:#800">// int(*)()</=
span><span><br>
</span></div></code></div><br>this will too fix problem with declaring retu=
rn type:<br><div style=3D"background-color:rgb(250,250,250);border-color:rg=
b(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><span style=3D"color:#008">auto</span><span> a4 </span><span sty=
le=3D"color:#660">=3D</span><span> </span><span style=3D"color:#660">[](</s=
pan><span style=3D"color:#008">auto</span><span> a</span><span style=3D"col=
or:#660">)</span><span> </span><span style=3D"color:#660">-></span><span=
> </span><span style=3D"color:#008">int</span><span style=3D"color:#660">*<=
/span><span> </span><span style=3D"color:#660">=3D</span><span> </span><spa=
n style=3D"color:#660">(</span><span>a</span><span style=3D"color:#660">);<=
/span><span> </span><span style=3D"color:#800">// without '=3D' we have [](=
auto a) -> int*(a) that is example of ambiguity in N3560</span><span><br=
>
</span></div></code></div><br>this new syntax will make handling comma intu=
itive:<br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><cod=
e><div>
<span style=3D"color:#008">int</span><span> a</span><span style=3D"color:#6=
60">;</span><span><br>foo</span><span style=3D"color:#660">(</span><span>a =
</span><span style=3D"color:#660">=3D</span><span> </span><span style=3D"co=
lor:#066">5</span><span style=3D"color:#660">,</span><span> </span><span st=
yle=3D"color:#066">5</span><span style=3D"color:#660">);</span><span> </spa=
n><span style=3D"color:#800">// foo((a =3D 5), 5);</span><span><br>
bar</span><span style=3D"color:#660">([]</span><span> </span><span style=3D=
"color:#660">=3D</span><span> </span><span style=3D"color:#066">5</span><sp=
an style=3D"color:#660">,</span><span> </span><span style=3D"color:#066">5<=
/span><span style=3D"color:#660">);</span><span> </span><span style=3D"colo=
r:#800">// bar(([] =3D 5), 5);</span><span><br>
<br></span><span style=3D"color:#008">int</span><span> b </span><span style=
=3D"color:#660">=3D</span><span> a </span><span style=3D"color:#660">=3D</s=
pan><span> </span><span style=3D"color:#066">5</span><span style=3D"color:#=
660">,</span><span> c</span><span style=3D"color:#660">;</span><span> </spa=
n><span style=3D"color:#800">// int b =3D (a =3D 5), c;</span><span><br>
</span><span style=3D"color:#606">Func</span><span> f </span><span style=3D=
"color:#660">=3D</span><span> </span><span style=3D"color:#660">[=3D](</spa=
n><span style=3D"color:#008">int</span><span style=3D"color:#660">)-></s=
pan><span style=3D"color:#008">int</span><span> </span><span style=3D"color=
:#660">=3D</span><span> a</span><span style=3D"color:#660">,</span><span> h=
</span><span style=3D"color:#660">;</span><span> </span><span style=3D"colo=
r:#800">// Func f =3D ([=3D]->int =3D a), h;</span><span><font color=3D"=
#888888"><span><br>
</span></font></span></div></code></div><span><font color=3D"#888888"><br><=
br></font></span></blockquote><div><br></div><div><br></div><div>Someone el=
se (Ivan Sorokin) suggested requiring a colon to separate the single-lambda=
-body-expression from its declarator. FWIW, I do like the suggestion, and p=
refer the colon (which Dave Abrahams reminded us has precedence in python) =
to the assignment operator (since we are not really assigning a value but d=
escribing how the result will be computed whenever the lambda is invoked).<=
br>
</div><div><br></div><div>So for e.g.<br><br></div><div>auto a2 =3D [](int)=
: 2.5;<br></div><div>auto a3 =3D [] : (int) 2.5;<br></div><div>auto a4 =3D=
[](auto a) -> int* : (a);<br></div><div>bar([] : 5, 5);<br></div><div>F=
unc f =3D [=3D](int)->int : a, h;<br>
<br></div><div>What do the rest of you think?<br><br></div><div>thanks!<br>=
</div></div></div></div></blockquote><div><br>I'd say that it's better solv=
ed by requiring that you use a parameter list. Even for no parameters. Thus=
`[]()` is the most minimalistic lambda inducer possible. It's only one cha=
racter more than `[]:`, and it would be clear from the rules what it means.=
Therefore, `[](int)2.5` would have a very clear meaning.<br></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_2020_22650035.1365341808926--
.
Author: inkwizytoryankes@gmail.com
Date: Sun, 7 Apr 2013 08:02:14 -0700 (PDT)
Raw View
------=_Part_907_11099519.1365346934225
Content-Type: text/plain; charset=ISO-8859-1
On Sunday, April 7, 2013 3:36:48 PM UTC+2, Nicol Bolas wrote:
>
> I'd say that it's better solved by requiring that you use a parameter
> list. Even for no parameters. Thus `[]()` is the most minimalistic lambda
> inducer possible. It's only one character more than `[]:`, and it would be
> clear from the rules what it means. Therefore, `[](int)2.5` would have a
> very clear meaning.
>
but rigth now you can skip `()`:
auto a = []{ std::cout << 42; };
I dont see big differences between `=` and `:`.
I prefer equal sign but I dont see any problems with colon. Both are equal
readable (most unreadable examples :>):
auto a=b?[]:c?d:[]:e?3:4:f; //colon version
auto i=[]=j=[]=k; //equal version
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
------=_Part_907_11099519.1365346934225
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><br>On Sunday, April 7, 2013 3:36:48 PM UTC+2, Nicol Bolas wrote:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;"><div><br>I'd say that it's bette=
r solved by requiring that you use a parameter list. Even for no parameters=
.. Thus `[]()` is the most minimalistic lambda inducer possible. It's only o=
ne character more than `[]:`, and it would be clear from the rules what it =
means. Therefore, `[](int)2.5` would have a very clear meaning.<br></div></=
blockquote><div><br> but rigth now you can skip `()`:<br><div class=3D"pret=
typrint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(1=
87, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-wor=
d;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">[]{</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cou=
t </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: #066;" class=3D"styled-by-prettify">42</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #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"><br></span></div></code></div><br>I dont see big di=
fferences between `=3D` and `:`.<br>I prefer equal sign but I dont see any =
problems with colon. Both are equal readable (most unreadable examples :>=
;):<br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, =
250); border-color: rgb(187, 187, 187); border-style: solid; border-width: =
1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">?[]:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">c</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">d</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">:[]:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">3</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">4</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"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//c=
olon version</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D[]=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">j</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D[]=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">k</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: #800;" class=3D"=
styled-by-prettify">//equal version</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></div></code></div><br><br></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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_907_11099519.1365346934225--
.