Topic: operator try (was Proposal: Monadic
Author: Niall Douglas <nialldouglas14@gmail.com>
Date: Tue, 3 Oct 2017 14:58:48 -0700 (PDT)
Raw View
------=_Part_7417_584320452.1507067928201
Content-Type: multipart/alternative;
boundary="----=_Part_7418_391489926.1507067928202"
------=_Part_7418_391489926.1507067928202
Content-Type: text/plain; charset="UTF-8"
>
>
> P.S. I'll contact Nial to see if he can share his paper already.
>
>
I am highly hesitant as I haven't even got round to merging your list of
feedback into the proposed text. It's still literally as you saw it before
your feedback.
But I will do as you request anyway on a separate thread.
Niall
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/879b1725-a7cd-4950-af11-7f838f4f9475%40isocpp.org.
------=_Part_7418_391489926.1507067928202
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div text=3D"=
#000000" bgcolor=3D"#FFFFFF"><br>
P.S. I'll contact Nial to see if he can share his paper already.<br=
><br></div></blockquote><div><br></div><div>I am highly hesitant as I haven=
't even got round to merging your list of feedback into the proposed te=
xt. It's still literally as you saw it before your feedback.</div><div>=
<br></div><div>But I will do as you request anyway on a separate thread.</d=
iv><div><br></div><div>Niall=C2=A0</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/879b1725-a7cd-4950-af11-7f838f4f9475%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/879b1725-a7cd-4950-af11-7f838f4f9475=
%40isocpp.org</a>.<br />
------=_Part_7418_391489926.1507067928202--
------=_Part_7417_584320452.1507067928201--
.
Author: Ray Hamel <rayghamel@gmail.com>
Date: Tue, 3 Oct 2017 21:04:35 -0700 (PDT)
Raw View
------=_Part_7613_348186509.1507089875111
Content-Type: multipart/alternative;
boundary="----=_Part_7614_1495328085.1507089875111"
------=_Part_7614_1495328085.1507089875111
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I think it would make more sense and be more functional / useful for `try`=
=20
to
be an infix than a prefix operator, so you could do
return f(a) try g try h;
instead of
auto b =3D try f(a);
auto c =3D try g(b);
return try h(c);
Infix `try` would also be harder to confuse with its present use in
`try`-`catch` blocks. (And, for the same reason, simpler to parse as well).
Ray
On Tuesday, October 3, 2017 at 5:32:41 PM UTC-4, Vicente J. Botet Escriba=
=20
wrote:
>
> Le 03/10/2017 =C3=A0 18:23, 'Jeffrey Yasskin' via ISO C++ Standard - Futu=
re=20
> Proposals a =C3=A9crit :
>
> FWIW, I'd be more interested in a proposal to help std::optional take=20
> advantage of the monadic properties of the coroutines language feature.
>
>
> I believe this is orthogonal. We can have a monadic interface and a more=
=20
> user oriented interface close to co_await.
>
> While we can define operator co_await for optional, expected and=20
> result<T>, these types share something in common. They are some kind of=
=20
> SuccessOrError and have the possibility to know if there is one of them a=
nd=20
> to extract the Success value or the Failure Value.
>
> auto v =3D try opt_expr;
> =20
> to be translated in a much simpler and more efficient way.
>
> In addition using co_await on a type that doesn't suspend is not natural=
=20
> to some of us.
>
> Niall has started a draft paper that we are polishing. This operator try=
=20
> would be customized in a similar but simpler way to co_await.
>
> I've also a draft of SuccessOrError that I would like to finish for=20
> Albuquerque
> =20
> https://github.com/viboes/std-make/blob/master/doc/proposal/nullable/Valu=
edOrError.md
>
> Here it is an example:
>
> U h(T);
>
> X<T,E> f();
>
> X<U,E> g() {
> auto t =3D try f();
> return h(t); =20
> } =20
>
> The meaning of a try-expression is given by the following transformation
>
> X<U,E> g() {
> auto __trier =3D operator try(f());
> if ( __trier.failed() )
> return __trier.failure_value();
> auto t =3D __trier.success_value(); =20
> return h(t); =20
> } =20
>
>
> Any feedback on this papers is welcome.
>
> Vicente
>
> P.S. I'll contact Nial to see if he can share his paper already.
>
>
>
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7afe3e3e-7f0c-406b-a44e-ff38834c8d39%40isocpp.or=
g.
------=_Part_7614_1495328085.1507089875111
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I think it would make more sense and be more function=
al / useful for `<span style=3D"font-family: courier new, monospace;">try</=
span>` to<br></div><div>be an infix than a prefix operator, so you could do=
</div><div><br></div><div><div style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettypr=
int"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">try</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> g </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">try</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> h</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span></div></code></div><br>instead of</div><div><br></div><=
div><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(1=
87, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break=
-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"sub=
prettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">try</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</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"> c </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">try</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> g</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">try</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> h</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span></div></code></div><br>Infix `<span style=3D"fon=
t-family: courier new, monospace;">try</span>` would also be harder to conf=
use with its present use in</div><div>`<span style=3D"font-family: courier =
new, monospace;">try</span>`-<span style=3D"font-family: courier new, monos=
pace;"><font face=3D"arial,sans-serif">`</font>catch<font face=3D"arial,san=
s-serif">` blocks. (And, for the same reason, simpler to parse as well).</f=
ont></span></div><div><span style=3D"font-family: courier new, monospace;">=
<font face=3D"arial,sans-serif"><br></font></span></div><div><span style=3D=
"font-family: courier new, monospace;"><font face=3D"arial,sans-serif">Ray<=
/font></span><br></div><br>On Tuesday, October 3, 2017 at 5:32:41 PM UTC-4,=
Vicente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
">
=20
=20
=20
<div text=3D"#000000" bgcolor=3D"#FFFFFF">
<div>Le 03/10/2017 =C3=A0 18:23, 'Jeffrey
Yasskin' via ISO C++ Standard - Future Proposals a =C3=A9crit=C2=
=A0:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">FWIW, I'd be more interested in a proposal to he=
lp
std::optional take advantage of the monadic properties of the
coroutines language feature.</div>
</blockquote>
<br>
I believe this is orthogonal. We can have a monadic interface and a
more user oriented interface close to co_await.<br>
<br>
While we can define operator co_await for optional, expected and
result<T>, these types share something in common. They are
some kind of SuccessOrError and have the possibility to know if
there is one of them and to extract the Success value or the Failure
Value.<br>
<br>
=C2=A0=C2=A0=C2=A0 auto v =3D try opt_expr;<br>
=C2=A0=C2=A0=C2=A0 <br>
to be translated in a much simpler and more efficient way.<br>
<br>
In addition using co_await on a type that doesn't suspend is not
natural to some of us.<br>
<br>
Niall has started a draft paper that we are polishing.=C2=A0 This
operator try would be customized in a similar but simpler way to
co_await.<br>
<br>
I've also a draft of SuccessOrError that I would like to finish for
Albuquerque<br>
=C2=A0=C2=A0=C2=A0
<a href=3D"https://github.com/viboes/std-make/blob/master/doc/proposal/null=
able/ValuedOrError.md" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"th=
is.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fv=
iboes%2Fstd-make%2Fblob%2Fmaster%2Fdoc%2Fproposal%2Fnullable%2FValuedOrErro=
r.md\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGL0uLyOnJcLPrvRE-NyxDvLXY6SQ&#=
39;;return true;" onclick=3D"this.href=3D'https://www.google.com/url?q\=
x3dhttps%3A%2F%2Fgithub.com%2Fviboes%2Fstd-make%2Fblob%2Fmaster%2Fdoc%2Fpro=
posal%2Fnullable%2FValuedOrError.md\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NGL0uLyOnJcLPrvRE-NyxDvLXY6SQ';return true;">https://github.com/viboes/=
std-<wbr>make/blob/master/doc/proposal/<wbr>nullable/ValuedOrError.md</a><b=
r>
<br>
Here it is an example:<br>
<br>
U h(T);<br>
<br>
X<T,E> f();<br>
<br>
X<U,E> g() {<br>
=C2=A0=C2=A0=C2=A0 auto t =3D=C2=A0 try f();<br>
=C2=A0=C2=A0=C2=A0 return h(t);=C2=A0 <br>
}=C2=A0 <br>
<br>
The meaning of a try-expression is given by the following
transformation<br>
<br>
X<U,E> g() {<br>
=C2=A0=C2=A0=C2=A0 auto __trier =3D operator try(f());<br>
=C2=A0=C2=A0=C2=A0 if ( __trier.failed() )<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return __trier.failure_value=
();<br>
=C2=A0=C2=A0=C2=A0 auto t =3D __trier.success_value();=C2=A0=C2=A0=C2=
=A0 <br>
=C2=A0=C2=A0=C2=A0 return h(t);=C2=A0 <br>
}=C2=A0 <br>
<br>
<br>
Any feedback on this papers is welcome.<br>
<br>
Vicente<br>
<br>
P.S. I'll contact Nial to see if he can share his paper already.<br=
>
<br>
<blockquote type=3D"cite">
<div><br>
</div>
</blockquote>
<br>
</div>
</blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7afe3e3e-7f0c-406b-a44e-ff38834c8d39%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7afe3e3e-7f0c-406b-a44e-ff38834c8d39=
%40isocpp.org</a>.<br />
------=_Part_7614_1495328085.1507089875111--
------=_Part_7613_348186509.1507089875111--
.
Author: Ray Hamel <rayghamel@gmail.com>
Date: Tue, 3 Oct 2017 21:24:33 -0700 (PDT)
Raw View
------=_Part_7792_79288799.1507091073584
Content-Type: multipart/alternative;
boundary="----=_Part_7793_381538040.1507091073584"
------=_Part_7793_381538040.1507091073584
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
To clarify a bit, I'm suggesting infix `try` take an expression on the left=
=20
and a
callable on the right, so
return a try f try g try h;
would be the semantic equivalent of the second snippet (with prefix `try`).
Ray
On Wednesday, October 4, 2017 at 12:04:35 AM UTC-4, Ray Hamel wrote:
>
> I think it would make more sense and be more functional / useful for `try=
`=20
> to
> be an infix than a prefix operator, so you could do
>
> return f(a) try g try h;
>
> instead of
>
> auto b =3D try f(a);
> auto c =3D try g(b);
> return try h(c);
>
> Infix `try` would also be harder to confuse with its present use in
> `try`-`catch` blocks. (And, for the same reason, simpler to parse as=20
> well).
>
> Ray
>
> On Tuesday, October 3, 2017 at 5:32:41 PM UTC-4, Vicente J. Botet Escriba=
=20
> wrote:
>>
>> Le 03/10/2017 =C3=A0 18:23, 'Jeffrey Yasskin' via ISO C++ Standard - Fut=
ure=20
>> Proposals a =C3=A9crit :
>>
>> FWIW, I'd be more interested in a proposal to help std::optional take=20
>> advantage of the monadic properties of the coroutines language feature.
>>
>>
>> I believe this is orthogonal. We can have a monadic interface and a more=
=20
>> user oriented interface close to co_await.
>>
>> While we can define operator co_await for optional, expected and=20
>> result<T>, these types share something in common. They are some kind of=
=20
>> SuccessOrError and have the possibility to know if there is one of them =
and=20
>> to extract the Success value or the Failure Value.
>>
>> auto v =3D try opt_expr;
>> =20
>> to be translated in a much simpler and more efficient way.
>>
>> In addition using co_await on a type that doesn't suspend is not natural=
=20
>> to some of us.
>>
>> Niall has started a draft paper that we are polishing. This operator tr=
y=20
>> would be customized in a similar but simpler way to co_await.
>>
>> I've also a draft of SuccessOrError that I would like to finish for=20
>> Albuquerque
>> =20
>> https://github.com/viboes/std-make/blob/master/doc/proposal/nullable/Val=
uedOrError.md
>>
>> Here it is an example:
>>
>> U h(T);
>>
>> X<T,E> f();
>>
>> X<U,E> g() {
>> auto t =3D try f();
>> return h(t); =20
>> } =20
>>
>> The meaning of a try-expression is given by the following transformation
>>
>> X<U,E> g() {
>> auto __trier =3D operator try(f());
>> if ( __trier.failed() )
>> return __trier.failure_value();
>> auto t =3D __trier.success_value(); =20
>> return h(t); =20
>> } =20
>>
>>
>> Any feedback on this papers is welcome.
>>
>> Vicente
>>
>> P.S. I'll contact Nial to see if he can share his paper already.
>>
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/71754ee5-bdbd-4826-82f9-a0ccb4950335%40isocpp.or=
g.
------=_Part_7793_381538040.1507091073584
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">To clarify a bit, I'm suggesting infix `<span style=3D=
"font-family: courier new, monospace;">try</span>` take an expression on th=
e left and a<br>callable on the right, so<br><br><div style=3D"background-c=
olor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: s=
olid; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">try</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> f </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">try</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> g </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">try</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> h</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></di=
v></code></div><br><div>would be the semantic equivalent of the second snip=
pet (with prefix `<span style=3D"font-family: courier new, monospace;">try<=
/span>`).</div><div><br></div><div>Ray<br></div><br>On Wednesday, October 4=
, 2017 at 12:04:35 AM UTC-4, Ray Hamel wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddi=
ng-left: 1ex;"><div dir=3D"ltr"><div>I think it would make more sense and b=
e more functional / useful for `<span style=3D"font-family:courier new,mono=
space">try</span>` to<br></div><div>be an infix than a prefix operator, so =
you could do</div><div><br></div><div><div style=3D"background-color:rgb(25=
0,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1p=
x"><code><div><span style=3D"color:#008">return</span><span style=3D"color:=
#000"> f</span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">a</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">try</span><span style=3D"color:#000"> g </s=
pan><span style=3D"color:#008">try</span><span style=3D"color:#000"> h</spa=
n><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></span>=
</div></code></div><br>instead of</div><div><br></div><div><div style=3D"ba=
ckground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:=
solid;border-width:1px"><code><div><span style=3D"color:#008">auto</span><s=
pan style=3D"color:#000"> b </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#008">try</span><span =
style=3D"color:#000"> f</span><span style=3D"color:#660">(</span><span styl=
e=3D"color:#000">a</span><span style=3D"color:#660">);</span><span style=3D=
"color:#000"><br></span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> c </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">try</span><span style=3D=
"color:#000"> g</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#000">b</span><span style=3D"color:#660">);</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#008">return</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#008">try</span><span style=3D"color:#=
000"> h</span><span style=3D"color:#660">(</span><span style=3D"color:#000"=
>c</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br=
></span></div></code></div><br>Infix `<span style=3D"font-family:courier ne=
w,monospace">try</span>` would also be harder to confuse with its present u=
se in</div><div>`<span style=3D"font-family:courier new,monospace">try</spa=
n>`-<span style=3D"font-family:courier new,monospace"><font face=3D"arial,s=
ans-serif">`</font>catch<font face=3D"arial,sans-serif">` blocks. (And, for=
the same reason, simpler to parse as well).</font></span></div><div><span =
style=3D"font-family:courier new,monospace"><font face=3D"arial,sans-serif"=
><br></font></span></div><div><span style=3D"font-family:courier new,monosp=
ace"><font face=3D"arial,sans-serif">Ray</font></span><br></div><br>On Tues=
day, October 3, 2017 at 5:32:41 PM UTC-4, Vicente J. Botet Escriba wrote:<b=
lockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-=
left:1px #ccc solid;padding-left:1ex">
=20
=20
=20
<div text=3D"#000000" bgcolor=3D"#FFFFFF">
<div>Le 03/10/2017 =C3=A0 18:23, 'Jeffrey
Yasskin' via ISO C++ Standard - Future Proposals a =C3=A9crit=C2=
=A0:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">FWIW, I'd be more interested in a proposal to he=
lp
std::optional take advantage of the monadic properties of the
coroutines language feature.</div>
</blockquote>
<br>
I believe this is orthogonal. We can have a monadic interface and a
more user oriented interface close to co_await.<br>
<br>
While we can define operator co_await for optional, expected and
result<T>, these types share something in common. They are
some kind of SuccessOrError and have the possibility to know if
there is one of them and to extract the Success value or the Failure
Value.<br>
<br>
=C2=A0=C2=A0=C2=A0 auto v =3D try opt_expr;<br>
=C2=A0=C2=A0=C2=A0 <br>
to be translated in a much simpler and more efficient way.<br>
<br>
In addition using co_await on a type that doesn't suspend is not
natural to some of us.<br>
<br>
Niall has started a draft paper that we are polishing.=C2=A0 This
operator try would be customized in a similar but simpler way to
co_await.<br>
<br>
I've also a draft of SuccessOrError that I would like to finish for
Albuquerque<br>
=C2=A0=C2=A0=C2=A0
<a href=3D"https://github.com/viboes/std-make/blob/master/doc/proposal/null=
able/ValuedOrError.md" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"th=
is.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fv=
iboes%2Fstd-make%2Fblob%2Fmaster%2Fdoc%2Fproposal%2Fnullable%2FValuedOrErro=
r.md\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGL0uLyOnJcLPrvRE-NyxDvLXY6SQ&#=
39;;return true;" onclick=3D"this.href=3D'https://www.google.com/url?q\=
x3dhttps%3A%2F%2Fgithub.com%2Fviboes%2Fstd-make%2Fblob%2Fmaster%2Fdoc%2Fpro=
posal%2Fnullable%2FValuedOrError.md\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NGL0uLyOnJcLPrvRE-NyxDvLXY6SQ';return true;">https://github.com/viboes/=
std-<wbr>make/blob/master/doc/proposal/<wbr>nullable/ValuedOrError.md</a><b=
r>
<br>
Here it is an example:<br>
<br>
U h(T);<br>
<br>
X<T,E> f();<br>
<br>
X<U,E> g() {<br>
=C2=A0=C2=A0=C2=A0 auto t =3D=C2=A0 try f();<br>
=C2=A0=C2=A0=C2=A0 return h(t);=C2=A0 <br>
}=C2=A0 <br>
<br>
The meaning of a try-expression is given by the following
transformation<br>
<br>
X<U,E> g() {<br>
=C2=A0=C2=A0=C2=A0 auto __trier =3D operator try(f());<br>
=C2=A0=C2=A0=C2=A0 if ( __trier.failed() )<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return __trier.failure_value=
();<br>
=C2=A0=C2=A0=C2=A0 auto t =3D __trier.success_value();=C2=A0=C2=A0=C2=
=A0 <br>
=C2=A0=C2=A0=C2=A0 return h(t);=C2=A0 <br>
}=C2=A0 <br>
<br>
<br>
Any feedback on this papers is welcome.<br>
<br>
Vicente<br>
<br>
P.S. I'll contact Nial to see if he can share his paper already.<br=
>
=20
</div>
</blockquote></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/71754ee5-bdbd-4826-82f9-a0ccb4950335%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/71754ee5-bdbd-4826-82f9-a0ccb4950335=
%40isocpp.org</a>.<br />
------=_Part_7793_381538040.1507091073584--
------=_Part_7792_79288799.1507091073584--
.
Author: Todd Fleming <tbfleming@gmail.com>
Date: Wed, 4 Oct 2017 06:11:48 -0700 (PDT)
Raw View
------=_Part_8174_1486704175.1507122708969
Content-Type: multipart/alternative;
boundary="----=_Part_8175_1223612708.1507122708970"
------=_Part_8175_1223612708.1507122708970
Content-Type: text/plain; charset="UTF-8"
Maybe a library function could do this:
return try_(a, f, g, h);
Todd
On Wednesday, October 4, 2017 at 12:24:33 AM UTC-4, Ray Hamel wrote:
>
> To clarify a bit, I'm suggesting infix `try` take an expression on the
> left and a
> callable on the right, so
>
> return a try f try g try h;
>
> would be the semantic equivalent of the second snippet (with prefix `try
> `).
>
> Ray
>
> On Wednesday, October 4, 2017 at 12:04:35 AM UTC-4, Ray Hamel wrote:
>>
>> I think it would make more sense and be more functional / useful for `try`
>> to
>> be an infix than a prefix operator, so you could do
>>
>> return f(a) try g try h;
>>
>> instead of
>>
>> auto b = try f(a);
>> auto c = try g(b);
>> return try h(c);
>>
>> Infix `try` would also be harder to confuse with its present use in
>> `try`-`catch` blocks. (And, for the same reason, simpler to parse as
>> well).
>>
>> Ray
>>
>>>
>>>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f936c4ce-7661-4785-a017-5d427c25776b%40isocpp.org.
------=_Part_8175_1223612708.1507122708970
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Maybe a library function could do this:<div><br></div><div=
><div style=3D"border-width: 1px; border-style: solid; border-color: rgb(18=
7, 187, 187); background-color: rgb(250, 250, 250);"><code><span style=3D"c=
olor: rgb(0, 0, 136);">return</span><span style=3D"color: rgb(0, 0, 0);">=
=C2=A0try_(a,</span><span style=3D"color: rgb(0, 0, 0);">=C2=A0f,=C2=A0</sp=
an><span style=3D"color: rgb(0, 0, 0);">g,</span><span style=3D"color: rgb(=
0, 0, 0);">=C2=A0h)</span><span style=3D"color: rgb(102, 102, 0);">;</span>=
</code></div><br><div>Todd</div></div><div><br>On Wednesday, October 4, 201=
7 at 12:24:33 AM UTC-4, Ray Hamel wrote:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr">To clarify a bit, I'm suggesting infix `<spa=
n style=3D"font-family:courier new,monospace">try</span>` take an expressio=
n on the left and a<br>callable on the right, so<br><br><div style=3D"backg=
round-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:sol=
id;border-width:1px"><code><div><span style=3D"color:#008">return</span><sp=
an style=3D"color:#000"> a </span><span style=3D"color:#008">try</span><spa=
n style=3D"color:#000"> f </span><span style=3D"color:#008">try</span><span=
style=3D"color:#000"> g </span><span style=3D"color:#008">try</span><span =
style=3D"color:#000"> h</span><span style=3D"color:#660">;</span></div></co=
de></div><br><div>would be the semantic equivalent of the second snippet (w=
ith prefix `<span style=3D"font-family:courier new,monospace">try</span>`).=
</div><div><br></div><div>Ray<br></div><br>On Wednesday, October 4, 2017 at=
12:04:35 AM UTC-4, Ray Hamel wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><div>I think it would make more sense and be more functio=
nal / useful for `<span style=3D"font-family:courier new,monospace">try</sp=
an>` to<br></div><div>be an infix than a prefix operator, so you could do</=
div><div><br></div><div><div style=3D"background-color:rgb(250,250,250);bor=
der-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div>=
<span style=3D"color:#008">return</span><span style=3D"color:#000"> f</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">a</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">try</span><span style=3D"color:#000"> g </span><span styl=
e=3D"color:#008">try</span><span style=3D"color:#000"> h</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br></span></div></code>=
</div><br>instead of</div><div><br></div><div><div style=3D"background-colo=
r:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-=
width:1px"><code><div><span style=3D"color:#008">auto</span><span style=3D"=
color:#000"> b </span><span style=3D"color:#660">=3D</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">try</span><span style=3D"colo=
r:#000"> f</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
00">a</span><span style=3D"color:#660">);</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#008">auto</span><span style=3D"color:#000"=
> c </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">try</span><span style=3D"color:#000"> g<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#000">b</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">return</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#008">try</span><span style=3D"color:#000"> h</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">c</span><span s=
tyle=3D"color:#660">);</span><span style=3D"color:#000"><br></span></div></=
code></div><br>Infix `<span style=3D"font-family:courier new,monospace">try=
</span>` would also be harder to confuse with its present use in</div><div>=
`<span style=3D"font-family:courier new,monospace">try</span>`-<span style=
=3D"font-family:courier new,monospace"><font face=3D"arial,sans-serif">`</f=
ont>catch<font face=3D"arial,sans-serif">` blocks. (And, for the same reaso=
n, simpler to parse as well).</font></span></div><div><span style=3D"font-f=
amily:courier new,monospace"><font face=3D"arial,sans-serif"><br></font></s=
pan></div><div><span style=3D"font-family:courier new,monospace"><font face=
=3D"arial,sans-serif">Ray</font></span><br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div text=3D"#000000" bgcolor=3D"#FFFFFF"><br>
=20
</div>
</blockquote></div></blockquote></div></blockquote></div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f936c4ce-7661-4785-a017-5d427c25776b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f936c4ce-7661-4785-a017-5d427c25776b=
%40isocpp.org</a>.<br />
------=_Part_8175_1223612708.1507122708970--
------=_Part_8174_1486704175.1507122708969--
.
Author: Barry Revzin <barry.revzin@gmail.com>
Date: Wed, 4 Oct 2017 07:01:01 -0700 (PDT)
Raw View
------=_Part_7411_624698989.1507125661921
Content-Type: multipart/alternative;
boundary="----=_Part_7412_2139653307.1507125661922"
------=_Part_7412_2139653307.1507125661922
Content-Type: text/plain; charset="UTF-8"
On Tuesday, October 3, 2017 at 11:04:35 PM UTC-5, Ray Hamel wrote:
>
> I think it would make more sense and be more functional / useful for `try`
> to
> be an infix than a prefix operator, so you could do
>
> return f(a) try g try h;
>
> instead of
>
> auto b = try f(a);
> auto c = try g(b);
> return try h(c);
>
The point of try is to alleviate the pain that is having to check a bunch
of SuccessOrErrors and have nice syntax to just properly return in those
cases. It doesn't make sense to me to think about try as being associated
with some callable - it's just a hook for returning early.
optional<A> maybe_a();
optional<B> maybe_b();
optional<C> maybe_c();
Z foo(A, B, C);
optional<Z> maybe_foo() {
// today
auto oa = maybe_a();
if (!oa) return nullopt;
auto ob = maybe_b();
if (!ob) return nullopt;
auto oc = maybe_c();
if (!oc) return nullopt;
return foo(*oa, *ob, *oc);
// with Simon's paper, we can use bind, but it does quite badly in this
particular case
// which shouldn't be interpreted as a negative against the paper -
this is just the worst case
// in my view, the map/bind interface and the try interface are
orthogonal and both desirable
return maybe_a().bind([=](A a){
return maybe_b().bind([=](B b){
return maybe_c().map([=](C c){
return foo(a, b, c);
});
});
});
// ... which is why it'd be nice to additionally have something like
the Rust/Swift try
auto a = try maybe_a();
auto b = try maybe_b();
auto c = try maybe_c();
return foo(a, b, c);
}
That last one is pretty nice to read, it's syntactically clear that these
things can fail but without all the noise from the first section.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/54096a87-4a01-410a-a077-5fa5c3294df7%40isocpp.org.
------=_Part_7412_2139653307.1507125661922
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Tuesday, October 3, 2017 at 11:04:35 PM UTC-5, =
Ray Hamel wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div>I think it would make more sense and be more functional / useful fo=
r `<span style=3D"font-family:courier new,monospace">try</span>` to<br></di=
v><div>be an infix than a prefix operator, so you could do</div><div><br></=
div><div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(1=
87,187,187);border-style:solid;border-width:1px"><code><div><span style=3D"=
color:#008">return</span><span style=3D"color:#000"> f</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">a</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">try</span><span style=3D"color:#000"> g </span><span style=3D"color:#008=
">try</span><span style=3D"color:#000"> h</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"><br></span></div></code></div><br>instea=
d of</div><div><br></div><div><div style=3D"background-color:rgb(250,250,25=
0);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><code=
><div><span style=3D"color:#008">auto</span><span style=3D"color:#000"> b <=
/span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">try</span><span style=3D"color:#000"> f</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">a</span><spa=
n style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span=
style=3D"color:#008">auto</span><span style=3D"color:#000"> c </span><span=
style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">try</span><span style=3D"color:#000"> g</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000">b</span><span style=3D"=
color:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#008">return</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">try</span><span style=3D"color:#000"> h</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">c</span><span style=3D"color:#6=
60">);</span></div></code></div></div></div></blockquote><div><br></div><di=
v><br></div><div>The point of try is to alleviate the pain that is having t=
o check a bunch of SuccessOrErrors and have nice syntax to just properly re=
turn in those cases. It doesn't make sense to me to think about try as =
being associated with some callable - it's just a hook for returning ea=
rly.=C2=A0</div><div><br></div><div><div class=3D"prettyprint" style=3D"bac=
kground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border=
-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pr=
ettyprint"><div class=3D"subprettyprint"><font color=3D"#660066"><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">optional</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">A</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> maybe_a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>optional</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">B</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> m=
aybe_b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>optiona=
l</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">C</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> maybe_c</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>Z foo</span><span style=3D"colo=
r: #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"styled-b=
y-prettify"> B</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> C</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>optional</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">Z</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> maybe_foo</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// today</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> oa </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> maybe_a</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">oa</span><spa=
n 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">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> nullopt</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 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> ob </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> maybe_b</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">ob</span><spa=
n 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">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> nullopt</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 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> oc </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> maybe_c</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">oc</span><spa=
n 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">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> nullopt</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(*</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">oa</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">*</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">ob</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;" class=
=3D"styled-by-prettify">oc</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">// with Simon's paper, we can use bind, but it does=
quite badly in this particular case</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">// which shouldn't be interpreted as =
a negative against the paper - this is just the worst case</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// in my view, the =
map/bind interface and the try interface are orthogonal and both desirable<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> maybe_=
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">().</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">bind</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">([=3D](</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">A a</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 =C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> maybe_b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">().</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">bind</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">([=3D](</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">B b</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">){</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> maybe_c</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">().</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">map</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">([=3D](</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">C c</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">){</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"s=
tyled-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"styled-by-prettify"> b</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> c</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">});</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =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"><br>=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"><br><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
.... which is why it'd be nice to additionally have something like the R=
ust/Swift try</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> 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: #008;" class=3D"styled-by-prettify">try</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> maybe_a</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">try</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> maybe_b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> c </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">try</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> maybe_c</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 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> foo</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"=
styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span></font></di=
v></code></div><br>That last one is pretty nice to read, it's syntactic=
ally clear that these things can fail but without all the noise from the fi=
rst section.=C2=A0</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/54096a87-4a01-410a-a077-5fa5c3294df7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/54096a87-4a01-410a-a077-5fa5c3294df7=
%40isocpp.org</a>.<br />
------=_Part_7412_2139653307.1507125661922--
------=_Part_7411_624698989.1507125661921--
.