Topic: await do-catch statement (was range-based if)
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 13 Nov 2014 08:31:25 +0100
Raw View
This is a multi-part message in MIME format.
--------------060308030203060304090307
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 13/11/14 02:59, Gor Nishanov a =C3=A9crit :
>
> I think it is a cool idea.
>
Glad to here you.
>
> Though for me to become enthusiastic about it, I need to see a real=20
> example where using do-catch is significantly better than using=20
> smaller functions (or even named lambdas).
>
> Essentially, I think that if the same goal can be achieved by=20
> structuring your code differently, it is goodness.
>
I believe that the await proposals are missing the error handling part.=20
They manage only the error propagation part.
In order to be able to handle errors the user needs to remove the usage=20
of await, try to get the value and rely on exception handling. As you=20
said you must use an auxiliary function or lambda. While I'm completely=20
for small function, if a function know ow to handle some errors I don't=20
know why we would need to split it in two.
M<T> f() {
auto x =3D await f1();
auto y =3D await f2(x);
return g(x,y);
}
....
try {
auto x =3D f().get(); // if M is future
// auto x =3D f().value() // if M is expected
//auto x =3D other syntax in other cases.
....
} catch () {
...
}
with do-catch
do {
auto x =3D await f1();
auto y =3D await f2(x);
return g(x,y);
} catch () {
....
}
One of the additional problems await solves is that we have an=20
homogeneous interface to get the value of a Monad. Using directly the=20
underlying type interface will not work on generic code. Of course, we=20
could define a more generic interface to get the value, but this is not=20
yet there.
The best I can do without the suggested do-catch is either to don't use=20
await
try {
auto x =3D f1().get(); // Not generic !!!
auto y =3D f2(x).get(); // Not generic !!!
return g(x,y);
} catch () {
...
}
or wrap them on a lambda
try {
*return**[&] {*****
auto x =3D await f1();
auto y =3D await f2(x);
return g(x,y);
***} ()*
} catch () {
...
}
BTW, what is the expected behavior of
auto f() {
*try { *
auto x =3D await f1();
auto y =3D await f2(x);
return g(x,y);
***} catch () { *
...
*}**
*}
Would the try-catch catch all the exceptions or only the exception=20
thrown by the call to g(x,y)?
Or is this program bad formed and the user needs to remove the try-catch=20
when using await?
>
> Also, I would like to keep the initial proposal small to ensure ease=20
> of passing. Once it is in, we can pile on to add more things on top J.
>
I have no problem with incremental development as soon as the=20
limitations are identified and we have a plan to mitigate them ;-)
>
> In my example in PS, I was using futures, thus await was needed to=20
> strip temporal aspect. I was using Wrap to prevent expansion of error.=20
> As I mentioned before Wrap was doing: future<T> -> future<expected<T>>=20
> transformation. Await only strips one level, allowing expected to be=20
> checked for errors prior to dereference.
>
Sincerely, this seems not user friendly IMHO.
Let me know if the provided examples show when do-cath could be better.
Vicente
>
> Gor
>
> *From:*Vicente J. Botet Escriba [mailto:vicente.botet@wanadoo.fr]
> *Sent:* Wednesday, November 12, 2014 4:10 PM
> *To:* Gor Nishanov; std-proposals@isocpp.org
> *Subject:* Re: [std-proposals] Re: Range-based if versus - await=20
> do-catch statement
>
> Le 13/11/14 00:20, Gor Nishanov a =C3=A9crit :
>
> I highly recommend small functions and Sean Parent=E2=80=99s suggesti=
on of
> not having more than one for-loop in a function. J
>
> With smaller functions you can always write:
>
> Void foo() {
>
> for(x: bar()) {
>
> Do Something with X;
>
> Return;
>
> }
>
> Otherwise;
>
> }
>
> Also, if you are OK with using exceptions for control flow J, then
> you can use optional=E2=80=99s .value() to achieve nearly the same sy=
ntax
> as do-catch.
>
> *try* {
> auto&& item =3D ExpandSomething().value();
> DoSomething(item);
> } *catch* (...) { // if there is no such first element
> // unsuccessful path...
> }
>
>
> This make use of exceptions, that if I'm not wrong, is more expensive=20
> that just a jump.
>
> As much as I like N4134 there might be cases where using something
> else would be as good. J
>
> **
>
> *Gor*
>
> **
>
> *P.S.*
>
> Await will be useful where you use unconditional error propagation
> on most expands, such as
>
> M<T> f() {
>
> auto x =3D await f1();
>
> auto y =3D await f2(x);
>
> return g(x,y);
>
> }
>
> In those cases where you want to check for an error. You don=E2=80=99=
t
> have to use await at all for optional or expected.
>
> In case of the future, you may need a wrapper: future<T> ->
> future<Expected<T>>, so that await bar() will strip the temporal
> expected leaving expected<T> enabling you to check for the error.
>
> Thus you can use plain if. No need for try-catch
>
> I.e.
>
> future<T> f() {
>
> auto x =3D await f1();
>
> auto y =3D await WrapErrorWithExpected(f2(x));
>
> if (y.has_error())
>
> return DoSomething();
>
> else
>
> return g(x,y);
>
> }
>
> This is the same as returning optional<T> directly, which impose to=20
> make use of operator*(). I don't see the interest of the nesting.
> Could you come back to the OP example?
> My do-catch suggestion has the advantage to don't need to dereference=20
> the result and probably been more efficient than using exceptions.
>
> It is very similar to the Haskell do-notation for MonadError
>
> do { action1; action2; action3 } `catchError` handler
>
>
>
> Vicente
>
>
> *From:*Vicente J. Botet Escriba [mailto:vicente.botet@wanadoo.fr]
> *Sent:* Wednesday, November 12, 2014 2:30 PM
> *To:* std-proposals@isocpp.org <mailto:std-proposals@isocpp.org>;
> Gor Nishanov
> *Subject:* Re: [std-proposals] Re: Range-based if versus - await
> do-catch statement
>
> Le 11/11/14 22:34, Matthew Woehlke a =C3=A9crit :
>
> On 2014-11-11 16:12, Brent Friedman wrote:
>
> I've noted in our codebase that we lean heavily on the conven=
ience of
>
> range-based for even when it's not perhaps the best way to ex=
press an idea.
>
> =20
>
> //do something to the first item
>
> for (auto& Item : range)
>
> {
>
> DoSomething(Item);
>
> break;
>
> }
>
> =20
>
> auto first_or_null(auto range) -> decltype(&range.begin())
>
> {
>
> auto begin =3D range.begin();
>
> auto end =3D range.end();
>
> return (begin =3D=3D end ? nullptr : &(*begin));
>
> }
>
> =20
>
> if (auto item =3D first_or_null(range))
>
> =20
>
> Basically you want that, right? :-)
>
> =20
>
> I'm not sure if that actually works, and it requires an additiona=
l
>
> dereference when you go to use 'item', but OTOH it wouldn't requi=
re a
>
> language change...
>
> =20
>
> =20
>
> If the result of first_or_null (why not optional<T&>) is
> configured with *await*, would the following be a good syntax for you=
?
>
> *do* {
> auto& item =3D *await* first_or_null(range)) ;
> DoSomething(item);
> } *catch* (...) { // if there is no such element
> // unsuccessful path...
> }
>
> We will need to adapt *await* to jump to the *catch* part instead
> of returning from the function if there is no value.
>
> This is clearly more complex than your original proposal, but it
> introduces a mechanism to catch the await errors, which could be
> applicable to other cases.
>
> I have used *do* instead of *try* to recall the Haskell
> do-notation, and because the semantic and the efficiency, while
> close, would be quite different.
>
> Another possibility is to configure directly any range with await
>
> *do* {
> auto& item =3D *await* range ;
> DoSomething(item);
> } *catch* (...) { // if there is no such first element
> // unsuccessful path...
> }
>
> The next question is, how would perform the generated code ? Would
> it be as efficient as
>
> if (!std::empty(range)) {
>
> DoSomething(*begin(range));
> } else {
> // unsuccessful path...
> }
>
>
>
> Gor what do you think?
>
> Vicente
>
--=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/.
--------------060308030203060304090307
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix"><br>
Le 13/11/14 02:59, Gor Nishanov a =C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:6e1462b914214c95a4ff7102f53a9755@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">I
think it is a cool idea.<o:p></o:p></span></p>
</div>
</blockquote>
Glad to here you.<br>
<blockquote
cite=3D"mid:6e1462b914214c95a4ff7102f53a9755@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Though
for me to become enthusiastic about it, I need to see a real
example where using do-catch is significantly better than
using smaller functions (or even named lambdas).<o:p></o:p></sp=
an></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Essentially,
I think that if the same goal can be achieved by structuring
your code differently, it is goodness.<o:p></o:p></span></p>
</div>
</blockquote>
I believe that the await proposals are missing the error handling
part. They manage only the error propagation part.<br>
In order to be able to handle errors the user needs to remove the
usage of await, try to get the value and rely on exception handling.
As you said you must use an auxiliary function or lambda. While I'm
completely for small function, if a function know ow to handle some
errors I don't know why we would need to split it in two. <br>
<br>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">M<T>
f() {</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D await f1();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await f2(x);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}<br>
<br>
... <br>
try {<br>
=C2=A0 auto x =3D f().get(); // if M is future<br>
</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0
// auto x =3D f().value() // if M is expected<br>
=C2=A0 //auto x =3D other syntax in other cases.<br>
</span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">...<br>
} catch () {<br>
=C2=A0 ...<br>
}<br>
<br>
with do-catch<br>
</span><br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">do
{<br>
</span></span>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D await f1();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await f2(x);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}
catch () {<br>
=C2=A0=C2=A0
...<br>
}<br>
</span><br>
One of the </span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">additional
</span>problems await solves is that we have an homogeneous
interface to get the value of a Monad. Using directly the
underlying type interface will not work on generic code. Of
course, we could define a more generic interface to get the value,
but this is not yet there.<br>
<br>
The best I can do without the suggested do-catch is</span> either
to don't use await <br>
<br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">try
{=C2=A0 </span></span><br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"></span></span></span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D f1()</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">.get();
</span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">//
Not generic !!!</span><o:p></o:p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D f2(x)</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">.get();
</span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">//
Not generic !!!</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}
catch () {<br>
=C2=A0 ...<br>
}<br>
<br>
or wrap them on a lambda<br>
<br>
</span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">try
{=C2=A0 </span></span><br>
<b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0
return</span></span></b><b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">
[&] {</span></b><b><o:p></o:p></b><b>
</b>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D await f1();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await f2(x);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<b>=C2=A0 </b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><b>}
()</b><br>
</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}
catch () {<br>
=C2=A0 ...<br>
}<br>
</span><br>
BTW, what is the expected behavior of<br>
<br>
</span>auto f() {<br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0
try {=C2=A0 </span></span></b><br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"></span></span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D await f1();</span><o:p></o:p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await f2(x);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<b>=C2=A0 </b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><b>}
catch () {=C2=A0 =C2=A0 </b><br>
=C2=A0=C2=A0=C2=A0 ...<br>
<b>=C2=A0
}</b><b><br>
</b>}<br>
</span></span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><br>
</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Would
the try-catch catch all the exceptions or only the exception
thrown by the call to g(x,y)?=C2=A0 <br>
Or is this program bad formed and the user needs to remove the
try-catch when using await?<br>
</span></span>
<blockquote
cite=3D"mid:6e1462b914214c95a4ff7102f53a9755@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Also,
I would like to keep the initial proposal small to ensure
ease of passing. Once it is in, we can pile on to add more
things on top
</span><span
style=3D"font-size:11.0pt;font-family:Wingdings;color:#1F497D">=
J</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">.</span></p>
</div>
</blockquote>
I have no problem with incremental development as soon as the
limitations are identified and we have a plan to mitigate them ;-)<br>
<blockquote
cite=3D"mid:6e1462b914214c95a4ff7102f53a9755@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">In
my example in PS, I was using futures, thus await was needed
to strip temporal aspect. I was using Wrap to prevent
expansion of error. As I mentioned before Wrap was doing:
future<T> -> future<expected<T>>
transformation. Await only strips one level, allowing
expected to be checked for errors prior to dereference.</span><=
/p>
</div>
</blockquote>
Sincerely, this seems not user friendly IMHO.<br>
<br>
Let me know if the provided examples show when do-cath could be
better.<br>
<br>
Vicente<br>
<blockquote
cite=3D"mid:6e1462b914214c95a4ff7102f53a9755@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Gor<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<div>
<div style=3D"border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class=3D"MsoNormal"><b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">From:</span></b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">
Vicente J. Botet Escriba
[<a class=3D"moz-txt-link-freetext" href=3D"mailto:vicente.=
botet@wanadoo.fr">mailto:vicente.botet@wanadoo.fr</a>]
<br>
<b>Sent:</b> Wednesday, November 12, 2014 4:10 PM<br>
<b>To:</b> Gor Nishanov; <a class=3D"moz-txt-link-abbreviat=
ed" href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a><b=
r>
<b>Subject:</b> Re: [std-proposals] Re: Range-based if
versus - await do-catch statement<o:p></o:p></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<div>
<p class=3D"MsoNormal">Le 13/11/14 00:20, Gor Nishanov a =C3=A9cr=
it=C2=A0:<o:p></o:p></p>
</div>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">I
highly recommend small functions and Sean Parent=E2=80=99s
suggestion of not having more than one for-loop in a
function.
</span><span
style=3D"font-size:11.0pt;font-family:Wingdings;color:#1F497D=
">J</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">With
smaller functions you can always write:</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Void
foo() {</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0
for(x: bar()) {
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0Do
Something with X;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
Return;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0
}
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0Otherwise;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Also,
if you are OK with using exceptions for control flow
</span><span
style=3D"font-size:11.0pt;font-family:Wingdings;color:#1F497D=
">J</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">,
then you can use optional=E2=80=99s .value() to achieve nearl=
y the
same syntax as do-catch.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal">=C2=A0=C2=A0=C2=A0 <b>try</b> { <br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auto&& item =3D ExpandSo=
mething().value();<br>
=C2=A0 =C2=A0=C2=A0=C2=A0 DoSomething(item);<br>
=C2=A0=C2=A0=C2=A0 } <b>catch</b> (...) { // if there is no suc=
h first
element<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // unsuccessful path... <br>
=C2=A0=C2=A0=C2=A0 }<br>
<br>
<br>
<o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal">This make use of exceptions, that if I'm
not wrong, is more expensive that just a jump.<br>
<br>
<o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">As
much as I like N4134 there might be cases where using
something else would be as good.
</span><span
style=3D"font-size:11.0pt;font-family:Wingdings;color:#1F497D=
">J</span><o:p></o:p></p>
<p class=3D"MsoNormal"><b>=C2=A0</b><o:p></o:p></p>
<p class=3D"MsoNormal"><b>Gor</b><o:p></o:p></p>
<p class=3D"MsoNormal"><b>=C2=A0</b><o:p></o:p></p>
<p class=3D"MsoNormal"><b>P.S.</b><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Await
will be useful where you use unconditional error
propagation on most expands, such as</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">M<T>
f() {</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D await f1();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await f2(x);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">In
those cases where you want to check for an error. You
don=E2=80=99t have to use await at all for optional or expect=
ed.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">In
case of the future, you may need a wrapper:
future<T> -> future<Expected<T>>, so
that await bar() will strip the temporal expected leaving
expected<T> enabling you to check for the error.</span>=
<o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Thus
you can use plain if. No need for try-catch</span><o:p></o:p>=
</p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">I.e.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">future<T>
f() {</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D await f1();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await WrapErrorWithExpected(f2(x));</span><o:p></o=
:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
if (y.has_error())
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return
DoSomething();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
else</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0return g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">This is the
same as returning optional<T> directly, which impose to
make use of operator*(). I don't see the interest of the
nesting.<br>
Could you come back to the OP example?<br>
My do-catch suggestion has the advantage to don't need to
dereference the result and probably been more efficient than
using exceptions.<br>
<br>
It is very similar to the Haskell do-notation for MonadError<o:p>=
</o:p></p>
<pre>do { action1; action2; action3 } `catchError` handler<o:p></o:=
p></pre>
<p class=3D"MsoNormal"><br>
<br>
Vicente <br>
<br>
<br>
<o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div style=3D"border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class=3D"MsoNormal"><b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">From:</span></b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">
Vicente J. Botet Escriba [<a moz-do-not-send=3D"true"
href=3D"mailto:vicente.botet@wanadoo.fr">mailto:vicente=
..botet@wanadoo.fr</a>]
<br>
<b>Sent:</b> Wednesday, November 12, 2014 2:30 PM<br>
<b>To:</b> <a moz-do-not-send=3D"true"
href=3D"mailto:std-proposals@isocpp.org">std-proposals@=
isocpp.org</a>;
Gor Nishanov<br>
<b>Subject:</b> Re: [std-proposals] Re: Range-based if
versus - await do-catch statement</span><o:p></o:p></p>
</div>
</div>
<p class=3D"MsoNormal">=C2=A0<o:p></o:p></p>
<div>
<p class=3D"MsoNormal">Le 11/11/14 22:34, Matthew Woehlke a
=C3=A9crit=C2=A0:<o:p></o:p></p>
</div>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<pre>On 2014-11-11 16:12, Brent Friedman wrote:<o:p></o:p></pre=
>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<pre>I've noted in our codebase that we lean heavily on the c=
onvenience of<o:p></o:p></pre>
<pre>range-based for even when it's not perhaps the best way =
to express an idea.<o:p></o:p></pre>
<pre>=C2=A0<o:p></o:p></pre>
<pre>//do something to the first item<o:p></o:p></pre>
<pre>for (auto& Item : range)<o:p></o:p></pre>
<pre>{<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0 DoSomething(Item);<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0 break;<o:p></o:p></pre>
<pre>}<o:p></o:p></pre>
</blockquote>
<pre>=C2=A0<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0 auto first_or_null(auto range) -> de=
cltype(&range.begin())<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0 {<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auto begin =3D =
range.begin();<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auto end =3D ra=
nge.end();<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return (begin =
=3D=3D end ? nullptr : &(*begin));<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0 }<o:p></o:p></pre>
<pre>=C2=A0<o:p></o:p></pre>
<pre>=C2=A0=C2=A0=C2=A0 if (auto item =3D first_or_null(range))=
<o:p></o:p></pre>
<pre>=C2=A0<o:p></o:p></pre>
<pre>Basically you want that, right? :-)<o:p></o:p></pre>
<pre>=C2=A0<o:p></o:p></pre>
<pre>I'm not sure if that actually works, and it requires an ad=
ditional<o:p></o:p></pre>
<pre>dereference when you go to use 'item', but OTOH it wouldn'=
t require a<o:p></o:p></pre>
<pre>language change...<o:p></o:p></pre>
<pre>=C2=A0<o:p></o:p></pre>
<pre>=C2=A0<o:p></o:p></pre>
</blockquote>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">If the
result of first_or_null (why not optional<T&>) is
configured with
<b>await</b>, would the following be a good syntax for you?<br>
<br>
=C2=A0=C2=A0=C2=A0 <b>do</b> { <br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auto& item =3D <b>await</b> =
first_or_null(range)) ;<br>
=C2=A0 =C2=A0=C2=A0=C2=A0 DoSomething(item);<br>
=C2=A0=C2=A0=C2=A0 } <b>catch</b> (...) { // if there is no suc=
h element<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // unsuccessful path... <br>
=C2=A0=C2=A0=C2=A0 }<br>
<br>
We will need to adapt <b>await</b> to jump to the <b>catch</b>
part instead of returning from the function if there is no
value.<br>
<br>
This is clearly more complex than your original proposal,
but it introduces a mechanism to catch the await errors,
which could be applicable to other cases.
<br>
<br>
I have used <b>do</b> instead of <b>try</b> to recall the
Haskell do-notation, and because the semantic and the
efficiency, while close, would be quite different.
<br>
<br>
Another possibility is to configure directly any range with
await<br>
<br>
=C2=A0=C2=A0=C2=A0 <b>do</b> { <br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auto& item =3D <b>await</b> =
range ;<br>
=C2=A0 =C2=A0=C2=A0=C2=A0 DoSomething(item);<br>
=C2=A0=C2=A0=C2=A0 } <b>catch</b> (...) { // if there is no suc=
h first
element<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // unsuccessful path... <br>
=C2=A0=C2=A0=C2=A0 }<br>
<br>
The next question is, how would perform the generated code ?
Would it be as efficient as<o:p></o:p></p>
<div>
<p class=3D"MsoNormal">=C2=A0 if (!std::empty(range)) {<o:p></o=
:p></p>
</div>
<div>
<p class=3D"MsoNormal">=C2=A0 =C2=A0 =C2=A0 DoSomething(*begin(=
range));<br>
=C2=A0 } else {<br>
=C2=A0 =C2=A0=C2=A0 // unsuccessful path... <br>
=C2=A0 }<o:p></o:p></p>
</div>
<p class=3D"MsoNormal"><br>
<br>
Gor what do you think?<br>
<br>
Vicente <o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
</div>
</blockquote>
<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--------------060308030203060304090307--
.
Author: Gor Nishanov <gorn@microsoft.com>
Date: Thu, 13 Nov 2014 16:47:30 +0000
Raw View
--_000_4d6e6ada8de145acb165d2045d7cab9eBL2PR03MB337namprd03pro_
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
>> I believe that the await proposals are missing the error handling part. =
They manage only the error propagation part.
I find that in large scale software ratio of exception handling to exceptio=
n propagation is hugely in favor of exception propagation.
There are very few places where you know what to do with an error, in one 1=
,000,000+ code base I worked on there were only 2 try-catches.
One was in a wrapper on the API boundary where we needed to stop exceptions=
, transform it to return an error to the user.
Another was when we had several possible ways of recovering from a problem.=
In both cases =E2=80=9Cif=E2=80=9D statement would not be more cumbersome =
compare to do-catch.
int SomeApi(int* output) {
if (auto result =3D foo()) {
*output =3D result.value();
return ERROR_SUCCESS;
}
else {
return result.error();
}
}
vs
int SomeApi(int* output) {
do {
*output =3D await result.value();
return ERROR_SUCCESS;
}
catch (Expected<int>& e) {
return e.error();
}
}
>> The best I can do without the suggested do-catch is either to don't use =
await
auto x =3D f1().get(); // Not generic !!!
We define what Monad interface should be in C++. We can have a common termi=
nology for all monadic types. It could be .value() or * or whatever else an=
d it will be generic.
>> BTW, what is the expected behavior of
auto f() {
try {
auto x =3D await f1();
auto y =3D await f2(x);
return g(x,y);
} catch () {
...
}
}
>> Would the try-catch catch all the exceptions or only the exception throw=
n by the call to g(x,y)?
Everything thrown between try catch including throws from unwrapping (if li=
brary writers chooses to use exceptions for error propagation).
In my example in PS, I was using futures, thus await was needed to strip te=
mporal aspect. I was using Wrap to prevent expansion of error. As I mention=
ed before Wrap was doing: future<T> -> future<expected<T>> transformation. =
Await only strips one level, allowing expected to be checked for errors pri=
or to dereference.
>> Sincerely, this seems not user friendly IMHO.
Possibly, but, this is for futures. For expected or optional if you care wh=
ether it has a value there is already a way to ask it about it. If statemen=
t is likely to be as readable as do-catch.
>> Let me know if the provided examples show when do-cath could be better.
Not yet =E2=98=BA.
Gor
--=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/.
--_000_4d6e6ada8de145acb165d2045d7cab9eBL2PR03MB337namprd03pro_
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle23
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1325818285;
mso-list-type:hybrid;
mso-list-template-ids:1189349336 -12823670 67698691 67698693 67698689 6769=
8691 67698693 67698689 67698691 67698693;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:=EF=82=B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:39.0pt;
text-indent:-.25in;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:75.0pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:=EF=82=A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:111.0pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:=EF=82=B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:147.0pt;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:183.0pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:=EF=82=A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:219.0pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:=EF=82=B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:255.0pt;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:291.0pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:=EF=82=A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:327.0pt;
text-indent:-.25in;
font-family:Wingdings;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=3D"white" lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">>> I believe that the await proposals are miss=
ing the error handling part. They manage only the error propagation part.<b=
r>
<br>
<span style=3D"font-size:11.0pt;font-family:"Calibri","sans-=
serif";color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">I find that in large scal=
e software ratio of exception handling to exception propagation is hugely i=
n favor of exception propagation.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">There are very few places=
where you know what to do with an error, in one 1,000,000+ code base I=
worked on there were only 2 try-catches.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">One was in a wrapper on t=
he API boundary where we needed to stop exceptions, transform it to return =
an error to the user.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">Another was when we had s=
everal possible ways of recovering from a problem. In both cases =E2=80=9Ci=
f=E2=80=9D statement would not be more cumbersome compare to do-catch.<o:p>=
</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">) {<o:p></o:p>=
</span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">if</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> (</span><span sty=
le=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-=
highlight:white">auto</span><span style=3D"font-size:9.5pt;font-family:Cons=
olas;background:white;mso-highlight:white">
result =3D foo()) {<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">
=3D result.value();<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> ERROR_SUCCESS=
;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">else</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;background:white;mso-highlight:white"> {<o:p></o:p></s=
pan></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> result.error(=
);<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white">}<o:p><=
/o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">vs<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">) {<o:p></o:p>=
</span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">do</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> {<o:p></o:p></spa=
n></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;=
background:white;mso-highlight:white">await</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;background:white;mso-highlight:white"> result.va=
lue();<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> ERROR_SUCCESS=
;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">catch</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;background:white;mso-highlight:white"> (Expected<<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backgr=
ound:white;mso-highlight:white">int</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white">>&
e) {<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> e.error();<o:=
p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white">}<o:p><=
/o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">>>
</span><span style=3D"font-size:11.0pt;font-family:"Calibri",&quo=
t;sans-serif";color:#1F497D">The best I can do without the suggested d=
o-catch is</span> either to don't use await
<br>
<span style=3D"font-size:11.0pt;font-family:"Calibri","sans-=
serif";color:#1F497D"> auto x =3D f1().get(); // Not=
generic !!!</span>
<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">We define what Monad inte=
rface should be in C++. We can have a common terminology for all mo=
nadic types. It could be .value() or * or whatever else and it will
be generic.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">>> BTW, what is the=
expected behavior of<br>
<br>
</span>auto f() {<br>
<b><span style=3D"font-size:11.0pt;font-family:"Calibri","sa=
ns-serif";color:#1F497D"> try {
</span></b><span style=3D"font-size:11.0pt;font-family:"Calibri",=
"sans-serif";color:#1F497D"><br>
auto x =3D await f1();</span> <o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> auto y=
=3D await f2(x);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> return=
g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><b> </b><b><span style=3D"font-size:11.0pt;fon=
t-family:"Calibri","sans-serif";color:#1F497D">} catch =
() {
</span></b><span style=3D"font-size:11.0pt;font-family:"Calibri",=
"sans-serif";color:#1F497D"><br>
...<br>
<b> }<br>
</b>}<br>
<br>
>> Would the try-catch catch all the exceptions or only the exception=
thrown by the call to g(x,y)?
<br>
<br>
</span><span style=3D"font-size:11.0pt;font-family:"Calibri",&quo=
t;sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">Everything thrown between=
try catch including throws from unwrapping (if library writers chooses to =
use exceptions for error propagation).<o:p></o:p></span></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">In my example in PS, I wa=
s using futures, thus await was needed to strip temporal aspect. I was usin=
g Wrap to prevent expansion of error. As I mentioned before
Wrap was doing: future<T> -> future<expected<T>> tran=
sformation. Await only strips one level, allowing expected to be checked fo=
r errors prior to dereference.</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal"><span style=3D"color:windowtext"><o:p> </o:p></=
span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">>>
</span>Sincerely, this seems not user friendly IMHO.<br>
<br>
<span style=3D"color:windowtext"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">Possibly, but, this is=
for futures. For expected or optional if you care whether it has a value t=
here is already a way to ask it about it. If statement is
likely to be as readable as do-catch.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><br>
<span style=3D"color:windowtext">>> </span>Let me know if the provide=
d examples show when do-cath could be better.<br>
<br>
<span style=3D"color:windowtext"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">Not yet
</span><span style=3D"font-size:11.0pt;font-family:Wingdings;color:windowte=
xt">J</span><span style=3D"font-size:11.0pt;font-family:"Calibri"=
,"sans-serif";color:windowtext">.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext"><o:p> </o:p></spa=
n></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">Gor<o:p></o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext"><o:p> </o:p></spa=
n></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--_000_4d6e6ada8de145acb165d2045d7cab9eBL2PR03MB337namprd03pro_--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 13 Nov 2014 22:34:56 +0100
Raw View
This is a multi-part message in MIME format.
--------------010504040108060701040101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 13/11/14 17:47, Gor Nishanov a =C3=A9crit :
>
> >> I believe that the await proposals are missing the error handling=20
> part. They manage only the error propagation part.
>
> I find that in large scale software ratio of exception handling to=20
> exception propagation is hugely in favor of exception propagation.
>
> There are very few places where you know what to do with an error, in=20
> one 1,000,000+ code base I worked on there were only 2 try-catches.
>
Agreed completely, there is no need for too much try-catch blocks.=20
However, this means that you can not use await when you want to recover=20
from the error. In order to use a try-catch an exception must be throw.=20
This seams a limitation to me.
> One was in a wrapper on the API boundary where we needed to stop=20
> exceptions, transform it to return an error to the user.
>
> Another was when we had several possible ways of recovering from a=20
> problem. In both cases =E2=80=9Cif=E2=80=9D statement would not be more c=
umbersome=20
> compare to do-catch.
>
> intSomeApi(int* output) {
>
> if(autoresult =3D foo()) {
>
> *output=3D result.value();
>
> returnERROR_SUCCESS;
>
> }
>
> else{
>
> returnresult.error();
>
> }
>
> }
>
> vs
>
> intSomeApi(int* output) {
>
> do{
>
> *output=3D awaitresult.value(); // (*)
>
> returnERROR_SUCCESS;
>
> }
>
> catch(Expected<int>& e) { // (**)
>
> returne.error();
>
> }
>
> }
>
I suspect you mean foo() in (*).
I would expect that the type in catch (**) would be exception_ptr if=20
result has type expected<int>.
Try to scale to more await expressions, and you will see why the if the=20
else doesn't scales.
intSomeApi(int* output1, int* output2) {
do{
*output1 =3D awaitfoo1();
*output2 =3D awaitfoo2();
returnSUCCESS;
}
catch(...) { // (*)
returnERROR
}
}
BTW, the interface of this function is too c-ish for my taste :(,=20
however is a good and simple example of error recovery that transforms=20
the error.
>
> >> The best I can do without the suggested do-catch is either to don't=20
> use await
> auto x =3D f1().get(); // Not generic !!!
>
> We define what Monad interface should be in C++. We can have a common=20
> terminology for all monadic types. It could be .value() or * or=20
> whatever else and it will be generic.
>
Yes , we can. But I believed that we have already found that common=20
terminology and that it was await ;-)
>
> >> BTW, what is the expected behavior of
>
> auto f() {
> *try { *
> auto x =3D await f1();
>
> auto y =3D await f2();
>
> return g(x,y);
>
> ***} catch (...) { *
> ...
> * }
> *}
>
> >> Would the try-catch catch all the exceptions or only the exception=20
> thrown by the call to g(x,y)?
>
> Everything thrown between try catch including throws from unwrapping=20
> (if library writers chooses to use exceptions for error propagation).
>
So the error returned by f1() or f(2) would not be caught, it will be=20
returned by the function f. This mean that try-catch and await don't=20
work well together. The user would need to use .get() or .value() or=20
whatever getter. But in this case the continuation style is broken as=20
the program will block.
auto f() {
*try { *
auto x =3D f1().value();
auto y =3D f2().value();
return g(x,y);
***} catch (...) { *
...
* }
*}
Alternatively the user could of course use .then, but I believed that=20
the purpose of await was to get rid of it and provide a more efficient=20
solution.
>
> In my example in PS, I was using futures, thus await was needed to
> strip temporal aspect. I was using Wrap to prevent expansion of
> error. As I mentioned before Wrap was doing: future<T> ->
> future<expected<T>> transformation. Await only strips one level,
> allowing expected to be checked for errors prior to dereference.
>
> >> Sincerely, this seems not user friendly IMHO.
>
> Possibly, but, this is for futures. For expected or optional if you=20
> care whether it has a value there is already a way to ask it about it.=20
> If statement is likely to be as readable as do-catch.
>
See below on scalability. do-catch allows to manage several error=20
conditions at once.
In my prototype of expected, I have defined a catch_error function that=20
is used to recovery from errors. I would expect that having await to=20
manage with the successful case and error propagation, the language=20
would be extended also to manage with error recovery. As I understand=20
the current proposal, you could not use await on the try-catch. That=20
means that the user would need to add split the function in two, one=20
that do the recover and the other that uses await.
The do-catch suggestion is a trial to take care of this issue. Surely=20
not completely satisfying, but I think there is something to do with.
>
>
> >>Let me know if the provided examples show when do-cath could be better.
>
> Not yet J.
>
>
and now?
Vicente
--=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/.
--------------010504040108060701040101
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix"><br>
Le 13/11/14 17:47, Gor Nishanov a =C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:4d6e6ada8de145acb165d2045d7cab9e@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle23
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1325818285;
mso-list-type:hybrid;
mso-list-template-ids:1189349336 -12823670 67698691 67698693 67698689 6769=
8691 67698693 67698689 67698691 67698693;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:=EF=82=B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:39.0pt;
text-indent:-.25in;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:75.0pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:=EF=82=A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:111.0pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:=EF=82=B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:147.0pt;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:183.0pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:=EF=82=A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:219.0pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:=EF=82=B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:255.0pt;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:291.0pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:=EF=82=A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:327.0pt;
text-indent:-.25in;
font-family:Wingdings;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
<div class=3D"WordSection1">
<p class=3D"MsoNormal">>> I believe that the await proposals
are missing the error handling part. They manage only the
error propagation part.<br>
<br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">I
find that in large scale software ratio of exception
handling to exception propagation is hugely in favor of
exception propagation.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">There
are very few places where you know what to do with an error,
in one 1,000,000+ code base I worked on there were only 2
try-catches.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
</div>
</blockquote>
Agreed completely, there is no need for too much try-catch blocks.
However, this means that you can not use await when you want to
recover from the error.=C2=A0 In order to use a try-catch an exception
must be throw. This seams a limitation to me.<br>
<br>
<blockquote
cite=3D"mid:4d6e6ada8de145acb165d2045d7cab9e@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">One
was in a wrapper on the API boundary where we needed to stop
exceptions, transform it to return an error to the user.<o:p></=
o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Another
was when we had several possible ways of recovering from a
problem. In both cases =E2=80=9Cif=E2=80=9D statement would not=
be more
cumbersome compare to do-catch.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SomeApi(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">)
{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">if</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">auto</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
result =3D foo()) {<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
=3D result.value();<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
ERROR_SUCCESS;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">else</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
result.error();<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">}<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">vs<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SomeApi(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">)
{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">do</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
=3D </span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">await</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
result.value(); // (*)<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
ERROR_SUCCESS;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">catch</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
(Expected<</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">>&
e) {=C2=A0 // (**)<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
e.error();<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">}<o:p></o:p></span></p>
</div>
</blockquote>
I suspect you mean foo() in (*).<br>
I would expect that the type in catch (**) would be exception_ptr if
result has type expected<int>.<br>
<br>
Try to scale to more await expressions, and you will see why the if
the else doesn't scales.<br>
<br>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SomeApi(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">1,
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"></span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"></span>2)
{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">do</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">1
=3D </span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">await</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
foo1();<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">2
=3D </span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">await</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
foo2();<o:p></o:p></span></p>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SUCCESS;<o:p></o:p></span>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">catch</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
(...</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">)
{=C2=A0 // (*)<o:p></o:p></span></p>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
ERROR<o:p></o:p></span>
<br>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}<o:p></o:p></span>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"><br>
}<br>
<br>
BTW, the interface of this function is too c-ish for my taste :(,
however is a good and simple example of error recovery that
transforms the error.<br>
</span>
<blockquote
cite=3D"mid:4d6e6ada8de145acb165d2045d7cab9e@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">>>
</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">The
best I can do without the suggested do-catch is</span>
either to don't use await
<br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto x =3D f1().get(); // Not generic !!!</span>
<o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">We
define what Monad interface should be in C++. We can have a
common terminology for all monadic types. It could be
.value() or * or whatever else and it will be generic.</span></=
p>
</div>
</blockquote>
Yes , we can. But I believed that we have already found that common
terminology and that it was await ;-)<br>
<blockquote
cite=3D"mid:4d6e6ada8de145acb165d2045d7cab9e@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">>>
BTW, what is the expected behavior of<br>
<br>
</span>auto f() {<br>
<b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0
try {=C2=A0
</span></b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><br>
=C2=A0=C2=A0=C2=A0 auto x =3D await f1();</span> <o:p></o:p></p=
>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D await f2();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><b>=C2=A0 </b><b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}
catch (...) {=C2=A0 =C2=A0
</span></b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><br>
=C2=A0=C2=A0=C2=A0 ...<br>
<b>=C2=A0 }<br>
</b>}<br>
<br>
>> Would the try-catch catch all the exceptions or
only the exception thrown by the call to g(x,y)?=C2=A0
<br>
<br>
</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Everything
thrown between try catch including throws from unwrapping
(if library writers chooses to use exceptions for error
propagation).</span></p>
</div>
</blockquote>
So the error returned by f1() or f(2) would not be caught, it will
be returned by the function f. This mean that try-catch and await
don't work well together. The user would need to use .get() or
.value() or whatever getter. But in this case the continuation style
is broken as the program will block.<br>
<br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"></span>auto
f() {<br>
<b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0
try {=C2=A0
</span></b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><br>
=C2=A0=C2=A0=C2=A0 auto x =3D f1().value();</span> <o:p></o:p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
auto y =3D f2().</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">value()</span>;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0
return g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><b>=C2=A0 </b><b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}
catch (...) {=C2=A0 =C2=A0
</span></b><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><br>
=C2=A0=C2=A0=C2=A0 ...<br>
<b>=C2=A0 }<br>
</b>}</span></p>
<br>
Alternatively the user could of course use .then, but I believed
that the purpose of await was to get rid of it and provide a more
efficient solution.<br>
<blockquote
cite=3D"mid:4d6e6ada8de145acb165d2045d7cab9e@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">In
my example in PS, I was using futures, thus await was
needed to strip temporal aspect. I was using Wrap to
prevent expansion of error. As I mentioned before Wrap was
doing: future<T> ->
future<expected<T>> transformation. Await only
strips one level, allowing expected to be checked for
errors prior to dereference.</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal"><span style=3D"color:windowtext"><o:p>=C2=A0=
</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">>>
</span>Sincerely, this seems not user friendly IMHO.<br>
<br>
<span style=3D"color:windowtext"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">Possibly,
but, this is for futures. For expected or optional if you
care whether it has a value there is already a way to ask it
about it. If statement is likely to be as readable as
do-catch.</span></p>
</div>
</blockquote>
See below on scalability. do-catch allows to manage several error
conditions at once.<br>
<br>
In my prototype of expected, I have defined a catch_error function
that is used to recovery from errors. I would expect that having
await to manage with the successful case and error propagation, the
language would be extended also to manage with error recovery. As I
understand the current proposal, you could not use await on the
try-catch. That means that the user would need to add split the
function in two, one that do the recover and the other that uses
await. <br>
<br>
The do-catch suggestion is a trial to take care of this issue.
Surely not completely satisfying, but I think there is something to
do with.<br>
<blockquote
cite=3D"mid:4d6e6ada8de145acb165d2045d7cab9e@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><br>
<span style=3D"color:windowtext">>> </span>Let me know if
the provided examples show when do-cath could be better.<br>
<br>
<span style=3D"color:windowtext"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">Not
yet
</span><span
style=3D"font-size:11.0pt;font-family:Wingdings;color:windowtex=
t">J</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext"><o:p>=C2=A0</o:p></span></p>
<br>
</div>
</blockquote>
and now?<br>
<br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--------------010504040108060701040101--
.
Author: Gor Nishanov <gorn@microsoft.com>
Date: Thu, 13 Nov 2014 21:58:34 +0000
Raw View
--_000_78439933ad9c4347a5dd5c1c76e41238BL2PR03MB337namprd03pro_
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
>> I would expect that the type in catch (**) would be exception_ptr if res=
ult has type expected<int>.
I surely hope not. =E2=98=BA
exception_ptr is a very poor mechanism for dealing with errors that are not=
rare, since it requires throw / catch to unpack the result.
(Until compilers can recognize this pattern and optimize it out).
Ideally, I would like to have a =E2=80=9CBetterThanExpected=E2=80=9D that s=
tores a triple: a value or an error_code and an (optional) exception.
Interface to expected would have:
exception() =E2=80=93 if error_code is stored and no exception, it will thr=
ow sysem_error(ec)
error_code() =E2=80=93 gives an ec [if exception is stored that is not deri=
ved from system_error, ec is synthesized as described below)
Exceptions derived from system_error has natural mapping to error_code, oth=
er exceptions can be mapped into =E2=80=9Csome-other-error-category=E2=80=
=9D with values matching all existing standard strongly typed exceptions an=
d some 0xFFFFFFF other for all other exceptions.
>> Try to scale to more await expressions, and you will see why the if the =
else doesn't scales.
int SomeApi(int* output1, int* output2) {
do {
*output1 =3D await foo1();
*output2 =3D await foo2();
return SUCCESS;
}
catch (...) { // (*)
return ERROR
}
}
>> That means that the user would need to add split the function in two, on=
e that do the recover and the other that uses await.
Yes. You have foreseen my argument. =E2=98=BA I can achieve the same effect=
with restructuring of the code.
expected<Pair<int,int>> foo() {
more computations here
return { await foo1(), await foo2() };
}
int SomeApi(int* output1, int* output2) {
if (auto result =3D foo1()) {
*output1 =3D result.first;
*output2 =3D result.second;
return SUCCESS;
}
else {
return result.error();
}
}
My argument is that it is acceptable as it allows to separate error handlin=
g logic completely from business logic. Thus, I do not see the transformati=
on above as limiting.
Now, I am weakly arguing against do-catch. I am not opposed to it. Just pla=
ying a devil=E2=80=99s advocate.
>> So the error returned by f1() or f(2) would not be caught, it will be re=
turned by the function f. This mean that try-catch and await don't work wel=
l together. The user would need to use .get() or .value() or whatever gette=
r. But in this case the continuation style is broken as the program will bl=
ock.
I do not understand this. If a library writer defined a coroutine_promise f=
or expected it needs to decide what error propagation mechanism it favors. =
He can chose to stop any exceptions in the body and resurface them as an ex=
ception stored in expected (define set_exception in the promise to stop all=
exceptions) and it can also choose to detect during unwrap whether an exce=
ption is stored in expected and call set_exceptions directly avoiding expen=
sive exception propagation.
It looks to me that seamless interactions with error propagating and except=
ion propagating code is possible.
>>The do-catch suggestion is a trial to take care of this issue. Surely not=
completely satisfying, but I think there is something to do with.
It has a reasonable syntax. We can keep it in the back pocket and use it wh=
en someone demands for it
>>>> Not yet =E2=98=BA.
>> and now?
Still neutral. I cannot find a compelling use case. All examples we had so =
far can be easily solved with minor restructuring of the code.
Gor
From: Vicente J. Botet Escriba [mailto:vicente.botet@wanadoo.fr]
Sent: Thursday, November 13, 2014 1:35 PM
To: Gor Nishanov; std-proposals@isocpp.org
Subject: Re: [std-proposals] Re: await do-catch statement (was range-based =
if)
Le 13/11/14 17:47, Gor Nishanov a =C3=A9crit :
>> I believe that the await proposals are missing the error handling part. =
They manage only the error propagation part.
I find that in large scale software ratio of exception handling to exceptio=
n propagation is hugely in favor of exception propagation.
There are very few places where you know what to do with an error, in one 1=
,000,000+ code base I worked on there were only 2 try-catches.
Agreed completely, there is no need for too much try-catch blocks. However,=
this means that you can not use await when you want to recover from the er=
ror. In order to use a try-catch an exception must be throw. This seams a =
limitation to me.
One was in a wrapper on the API boundary where we needed to stop exceptions=
, transform it to return an error to the user.
Another was when we had several possible ways of recovering from a problem.=
In both cases =E2=80=9Cif=E2=80=9D statement would not be more cumbersome =
compare to do-catch.
int SomeApi(int* output) {
if (auto result =3D foo()) {
*output =3D result.value();
return ERROR_SUCCESS;
}
else {
return result.error();
}
}
vs
int SomeApi(int* output) {
do {
*output =3D await result.value(); // (*)
return ERROR_SUCCESS;
}
catch (Expected<int>& e) { // (**)
return e.error();
}
}
I suspect you mean foo() in (*).
I would expect that the type in catch (**) would be exception_ptr if result=
has type expected<int>.
Try to scale to more await expressions, and you will see why the if the els=
e doesn't scales.
int SomeApi(int* output1, int* output2) {
do {
*output1 =3D await foo1();
*output2 =3D await foo2();
return SUCCESS;
}
catch (...) { // (*)
return ERROR
}
}
BTW, the interface of this function is too c-ish for my taste :(, however i=
s a good and simple example of error recovery that transforms the error.
>> The best I can do without the suggested do-catch is either to don't use =
await
auto x =3D f1().get(); // Not generic !!!
We define what Monad interface should be in C++. We can have a common termi=
nology for all monadic types. It could be .value() or * or whatever else an=
d it will be generic.
Yes , we can. But I believed that we have already found that common termino=
logy and that it was await ;-)
>> BTW, what is the expected behavior of
auto f() {
try {
auto x =3D await f1();
auto y =3D await f2();
return g(x,y);
} catch (...) {
...
}
}
>> Would the try-catch catch all the exceptions or only the exception throw=
n by the call to g(x,y)?
Everything thrown between try catch including throws from unwrapping (if li=
brary writers chooses to use exceptions for error propagation).
So the error returned by f1() or f(2) would not be caught, it will be retur=
ned by the function f. This mean that try-catch and await don't work well t=
ogether. The user would need to use .get() or .value() or whatever getter. =
But in this case the continuation style is broken as the program will block=
..
auto f() {
try {
auto x =3D f1().value();
auto y =3D f2().value();
return g(x,y);
} catch (...) {
...
}
}
Alternatively the user could of course use .then, but I believed that the p=
urpose of await was to get rid of it and provide a more efficient solution.
In my example in PS, I was using futures, thus await was needed to strip te=
mporal aspect. I was using Wrap to prevent expansion of error. As I mention=
ed before Wrap was doing: future<T> -> future<expected<T>> transformation. =
Await only strips one level, allowing expected to be checked for errors pri=
or to dereference.
>> Sincerely, this seems not user friendly IMHO.
Possibly, but, this is for futures. For expected or optional if you care wh=
ether it has a value there is already a way to ask it about it. If statemen=
t is likely to be as readable as do-catch.
See below on scalability. do-catch allows to manage several error condition=
s at once.
In my prototype of expected, I have defined a catch_error function that is =
used to recovery from errors. I would expect that having await to manage wi=
th the successful case and error propagation, the language would be extende=
d also to manage with error recovery. As I understand the current proposal,=
you could not use await on the try-catch. That means that the user would n=
eed to add split the function in two, one that do the recover and the other=
that uses await.
The do-catch suggestion is a trial to take care of this issue. Surely not c=
ompletely satisfying, but I think there is something to do with.
>> Let me know if the provided examples show when do-cath could be better.
Not yet =E2=98=BA.
and now?
Vicente
--=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/.
--_000_78439933ad9c4347a5dd5c1c76e41238BL2PR03MB337namprd03pro_
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle25
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=3D"white" lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">>>
</span>I would expect that the type in catch (**) would be exception_ptr if=
result has type expected<int>.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">I surely hope not. <span style=3D"font-family:Wingdi=
ngs">J</span><o:p></o:p></p>
<p class=3D"MsoNormal">exception_ptr is a very poor mechanism for dealing w=
ith errors that are not rare, since it requires throw / catch to unpack the=
result.<o:p></o:p></p>
<p class=3D"MsoNormal">(Until compilers can recognize this pattern and opti=
mize it out).<o:p></o:p></p>
<p class=3D"MsoNormal">Ideally, I would like to have a =E2=80=9CBetterThanE=
xpected=E2=80=9D that stores a triple: a value or an error_code and an (opt=
ional) exception.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Interface to expected would have:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">exception() =E2=80=93 if error_code is stored and no=
exception, it will throw sysem_error(ec)<o:p></o:p></p>
<p class=3D"MsoNormal">error_code() =E2=80=93 gives an ec [if exception is =
stored that is not derived from system_error, ec is synthesized as describe=
d below)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Exceptions derived from system_error has natural map=
ping to error_code, other exceptions can be mapped into =E2=80=9Csome-other=
-error-category=E2=80=9D with values matching all existing standard strongl=
y typed exceptions and some 0xFFFFFFF other for all
other exceptions.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">>> Try to scale=
to more await expressions, and you will see why the if the else doesn't sc=
ales.<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">1,
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">int</span><span style=3D"font-size:9.5pt;f=
ont-family:Consolas;background:white;mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">2) {</span><o:=
p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">do</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> {</span><o:p></o:=
p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">1
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;=
background:white;mso-highlight:white">await</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;background:white;mso-highlight:white"> foo1();</=
span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">2
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;=
background:white;mso-highlight:white">await</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;background:white;mso-highlight:white"> foo2();</=
span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.5pt;font-family:Consolas;=
background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> SUCCESS;</spa=
n>
<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">catch</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;background:white;mso-highlight:white"> (...) { =
// (*)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.5pt;font-family:Consolas;=
background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> ERROR</span>
<br>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white"> }</span>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white">
<br>
}<br>
<br>
<o:p></o:p></span></p>
<p class=3D"MsoNormal">>> That means that the user would need to add =
split the function in two, one that do the recover and the other that uses =
await.
<br>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white"><br>
</span>Yes. You have foreseen my argument. <span style=3D"font-family:Wingd=
ings">J</span> I can achieve the same effect with restructuring of the code=
..<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">expected<Pair<int,i=
nt>> foo() {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> =
more computations here<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> =
return { await foo1(), await foo2() };
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">}<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">1,
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">int</span><span style=3D"font-size:9.5pt;f=
ont-family:Consolas;background:white;mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">2) {</span><o:=
p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">if</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> (</span><span sty=
le=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-=
highlight:white">auto</span><span style=3D"font-size:9.5pt;font-family:Cons=
olas;background:white;mso-highlight:white">
result =3D </span><span style=3D"font-size:9.5pt;font-family:Consolas">foo=
1()) {</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">1
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas">result.fir=
st;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">2
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas">result.sec=
ond;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.5pt;font-family:Consolas;=
background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> SUCCESS;</spa=
n>
<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">else</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;background:white;mso-highlight:white"> {
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.5pt;font-family:Consolas;=
background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">
</span><span style=3D"font-size:9.5pt;font-family:Consolas">result.error();=
</span> <br>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white"> }</span>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white">
<br>
}<br>
<br>
</span><span style=3D"font-size:11.0pt;font-family:"Calibri",&quo=
t;sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">My argument is that it is=
acceptable as it allows to separate error handling logic completely from b=
usiness logic. Thus, I do not see the transformation above
as limiting.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">Now, I am weakly arguing =
against do-catch. I am not opposed to it. Just playing a devil=E2=80=99s ad=
vocate.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal">>> So the error returned by f1() or f(2) would=
not be caught, it will be returned by the function f. This mean that try-c=
atch and await don't work well together. The user would need to use .get() =
or .value() or whatever getter. But in this
case the continuation style is broken as the program will block.<br>
<br>
<span style=3D"font-size:11.0pt;font-family:"Calibri","sans-=
serif";color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">I do not understand this.=
If a library writer defined a coroutine_promise for expected it needs to d=
ecide what error propagation mechanism it favors. He can
chose to stop any exceptions in the body and resurface them as an exceptio=
n stored in expected (define set_exception in the promise to stop all excep=
tions) and it can also choose to detect during unwrap whether an exception =
is stored in expected and call set_exceptions
directly avoiding expensive exception propagation.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">It looks to me that seaml=
ess interactions with error propagating and exception propagating code is p=
ossible.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">>>The do-catch suggestion is a trial to take c=
are of this issue. Surely not completely satisfying, but I think there is s=
omething to do with.<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal">It has a reasonable syntax. We can keep it in the ba=
ck pocket and use it when someone demands for it<o:p></o:p></p>
<p class=3D"MsoNormal"><br>
<span style=3D"color:windowtext">>>>> </span><span style=3D"fon=
t-size:11.0pt;font-family:"Calibri","sans-serif";color:=
windowtext">Not yet
</span><span style=3D"font-size:11.0pt;font-family:Wingdings;color:windowte=
xt">J</span><span style=3D"font-size:11.0pt;font-family:"Calibri"=
,"sans-serif";color:windowtext">.</span><o:p></o:p></p>
<p class=3D"MsoNormal">>> and now?<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">Still neutral. I cannot f=
ind a compelling use case. All examples we had so far can be easily solved =
with minor restructuring of the code.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><br>
Gor<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<div>
<div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in =
0in 0in">
<p class=3D"MsoNormal"><b><span style=3D"font-size:11.0pt;font-family:"=
;Calibri","sans-serif";color:windowtext">From:</span></b><sp=
an style=3D"font-size:11.0pt;font-family:"Calibri","sans-ser=
if";color:windowtext"> Vicente J. Botet Escriba [mailto:vicente.botet@=
wanadoo.fr]
<br>
<b>Sent:</b> Thursday, November 13, 2014 1:35 PM<br>
<b>To:</b> Gor Nishanov; std-proposals@isocpp.org<br>
<b>Subject:</b> Re: [std-proposals] Re: await do-catch statement (was range=
-based if)<o:p></o:p></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<div>
<p class=3D"MsoNormal"><br>
Le 13/11/14 17:47, Gor Nishanov a =C3=A9crit :<o:p></o:p></p>
</div>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal">>> I believe that the await proposals are miss=
ing the error handling part. They manage only the error propagation part.<b=
r>
<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">I find that in large scal=
e software ratio of exception handling to exception propagation is hugely i=
n favor of exception propagation.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">There are very few places=
where you know what to do with an error, in one 1,000,000+ code base I=
worked on there were only 2 try-catches.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
</blockquote>
<p class=3D"MsoNormal">Agreed completely, there is no need for too much try=
-catch blocks. However, this means that you can not use await when you want=
to recover from the error. In order to use a try-catch an exception =
must be throw. This seams a limitation
to me.<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">One was in a wrapper on t=
he API boundary where we needed to stop exceptions, transform it to return =
an error to the user.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">Another was when we had s=
everal possible ways of recovering from a problem. In both cases =E2=80=9Ci=
f=E2=80=9D statement would not be more cumbersome compare to do-catch.</spa=
n><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">) {</span><o:p=
></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">if</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> (</span><span sty=
le=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-=
highlight:white">auto</span><span style=3D"font-size:9.5pt;font-family:Cons=
olas;background:white;mso-highlight:white">
result =3D foo()) {</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">
=3D result.value();</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> ERROR_SUCCESS=
;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">else</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;background:white;mso-highlight:white"> {</span><o:p></=
o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> result.error(=
);</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white">}</span=
><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">vs</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">) {</span><o:p=
></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">do</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> {</span><o:p></o:=
p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;=
background:white;mso-highlight:white">await</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;background:white;mso-highlight:white"> result.va=
lue(); // (*)</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> ERROR_SUCCESS=
;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">catch</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;background:white;mso-highlight:white"> (Expected<<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backgr=
ound:white;mso-highlight:white">int</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white">>&
e) { // (**)</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> e.error();</s=
pan><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white">}</span=
><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">I suspect you mean fo=
o() in (*).<br>
I would expect that the type in catch (**) would be exception_ptr if result=
has type expected<int>.<br>
<br>
Try to scale to more await expressions, and you will see why the if the els=
e doesn't scales.<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:whi=
te">int</span><span style=3D"font-size:9.5pt;font-family:Consolas;backgroun=
d:white;mso-highlight:white"> SomeApi(</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;color:blue;background:white;mso-highlight:white">int<=
/span><span style=3D"font-size:9.5pt;font-family:Consolas;background:white;=
mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">1,
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">int</span><span style=3D"font-size:9.5pt;f=
ont-family:Consolas;background:white;mso-highlight:white">*
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:gray;backg=
round:white;mso-highlight:white">output</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white">2) {</span><o:=
p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">do</span><span style=3D"font-size:9.5pt;fo=
nt-family:Consolas;background:white;mso-highlight:white"> {</span><o:p></o:=
p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">1
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;=
background:white;mso-highlight:white">await</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;background:white;mso-highlight:white"> foo1();</=
span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; *</span><span style=3D"font-size:9.5pt;=
font-family:Consolas;color:gray;background:white;mso-highlight:white">outpu=
t</span><span style=3D"font-size:9.5pt;font-family:Consolas;background:whit=
e;mso-highlight:white">2
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;=
background:white;mso-highlight:white">await</span><span style=3D"font-size:=
9.5pt;font-family:Consolas;background:white;mso-highlight:white"> foo2();</=
span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.5pt;font-family:Consolas;=
background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> SUCCESS;</spa=
n>
<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:9.5pt;font-family:Consolas;background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">catch</span><span style=3D"font-size:9.5pt=
;font-family:Consolas;background:white;mso-highlight:white"> (...) { =
// (*)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.5pt;font-family:Consolas;=
background:white;mso-highlight:white"> &=
nbsp;
</span><span style=3D"font-size:9.5pt;font-family:Consolas;color:blue;backg=
round:white;mso-highlight:white">return</span><span style=3D"font-size:9.5p=
t;font-family:Consolas;background:white;mso-highlight:white"> ERROR</span>
<br>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white"> }</span>
<span style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-hi=
ghlight:white">
<br>
}<br>
<br>
BTW, the interface of this function is too c-ish for my taste :(, however i=
s a good and simple example of error recovery that transforms the error.<br=
>
<br>
</span><o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">>> The best I can d=
o without the suggested do-catch is</span> either to don't use await
<br>
<span style=3D"font-size:11.0pt;font-family:"Calibri","sans-=
serif";color:#1F497D"> auto x =3D f1().get(); // Not=
generic !!!</span>
<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">We define what Monad inte=
rface should be in C++. We can have a common terminology for all mo=
nadic types. It could be .value() or * or whatever else and it will
be generic.</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal">Yes , we can. But I believed that we have already fo=
und that common terminology and that it was await ;-)<br>
<br>
<o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> </span><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">>> BTW, what is the=
expected behavior of<br>
<br>
</span>auto f() {<br>
<b><span style=3D"font-size:11.0pt;font-family:"Calibri","sa=
ns-serif";color:#1F497D"> try {
</span></b><span style=3D"font-size:11.0pt;font-family:"Calibri",=
"sans-serif";color:#1F497D"><br>
auto x =3D await f1();</span> <o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> auto y=
=3D await f2();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> return=
g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><b> </b><b><span style=3D"font-size:11.0pt;fon=
t-family:"Calibri","sans-serif";color:#1F497D">} catch =
(...) {
</span></b><span style=3D"font-size:11.0pt;font-family:"Calibri",=
"sans-serif";color:#1F497D"><br>
...<br>
<b> }<br>
</b>}<br>
<br>
>> Would the try-catch catch all the exceptions or only the exception=
thrown by the call to g(x,y)?
<br>
<br>
<br>
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">Everything thrown between=
try catch including throws from unwrapping (if library writers chooses to =
use exceptions for error propagation).</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal">So the error returned by f1() or f(2) would not be c=
aught, it will be returned by the function f. This mean that try-catch and =
await don't work well together. The user would need to use .get() or .value=
() or whatever getter. But in this
case the continuation style is broken as the program will block.<br>
<br>
auto f() {<br>
<b><span style=3D"font-size:11.0pt;font-family:"Calibri","sa=
ns-serif";color:#1F497D"> try {
</span></b><span style=3D"font-size:11.0pt;font-family:"Calibri",=
"sans-serif";color:#1F497D"><br>
auto x =3D f1().value();</span> <o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> auto y=
=3D f2().value();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"> return=
g(x,y);</span><o:p></o:p></p>
<p class=3D"MsoNormal"><b> </b><b><span style=3D"font-size:11.0pt;fon=
t-family:"Calibri","sans-serif";color:#1F497D">} catch =
(...) {
</span></b><span style=3D"font-size:11.0pt;font-family:"Calibri",=
"sans-serif";color:#1F497D"><br>
...<br>
<b> }<br>
</b>}</span><o:p></o:p></p>
<p class=3D"MsoNormal"><br>
Alternatively the user could of course use .then, but I believed that the p=
urpose of await was to get rid of it and provide a more efficient solution.=
<br>
<br>
<o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">In my example in PS, I wa=
s using futures, thus await was needed to strip temporal aspect. I was usin=
g Wrap to prevent expansion of error. As I mentioned before
Wrap was doing: future<T> -> future<expected<T>> tran=
sformation. Await only strips one level, allowing expected to be checked fo=
r errors prior to dereference.</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal"><span style=3D"color:windowtext"> </span><o:p><=
/o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">>>
</span>Sincerely, this seems not user friendly IMHO.<br>
<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">Possibly, but, this is=
for futures. For expected or optional if you care whether it has a value t=
here is already a way to ask it about it. If statement is
likely to be as readable as do-catch.</span><o:p></o:p></p>
</blockquote>
<p class=3D"MsoNormal">See below on scalability. do-catch allows to manage =
several error conditions at once.<br>
<br>
In my prototype of expected, I have defined a catch_error function that is =
used to recovery from errors. I would expect that having await to manage wi=
th the successful case and error propagation, the language would be extende=
d also to manage with error recovery.
As I understand the current proposal, you could not use await on the try-c=
atch. That means that the user would need to add split the function in two,=
one that do the recover and the other that uses await.
<br>
<br>
The do-catch suggestion is a trial to take care of this issue. Surely not c=
ompletely satisfying, but I think there is something to do with.<br>
<br>
<o:p></o:p></p>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal"><br>
<span style=3D"color:windowtext">>> </span>Let me know if the provide=
d examples show when do-cath could be better.<br>
<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext">Not yet
</span><span style=3D"font-size:11.0pt;font-family:Wingdings;color:windowte=
xt">J</span><span style=3D"font-size:11.0pt;font-family:"Calibri"=
,"sans-serif";color:windowtext">.</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:windowtext"> </span><o:p></o:=
p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
</blockquote>
<p class=3D"MsoNormal">and now?<br>
<br>
Vicente<o:p></o:p></p>
</div>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--_000_78439933ad9c4347a5dd5c1c76e41238BL2PR03MB337namprd03pro_--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 14 Nov 2014 07:28:21 +0100
Raw View
This is a multi-part message in MIME format.
--------------070304060207010309020608
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 13/11/14 22:58, Gor Nishanov a =C3=A9crit :
>
> >> I would expect that the type in catch (**) would be exception_ptr if=
=20
> result has type expected<int>.
>
> I surely hope not. J
>
> exception_ptr is a very poor mechanism for dealing with errors that=20
> are not rare, since it requires throw / catch to unpack the result.
>
You are right. I wanted to say that the catch is not expected<T>, but=20
the stored exception.
>
> (Until compilers can recognize this pattern and optimize it out).
>
> Ideally, I would like to have a =E2=80=9CBetterThanExpected=E2=80=9D that=
stores a=20
> triple: a value or an error_code and an (optional) exception.
>
> Interface to expected would have:
>
> exception() =E2=80=93 if error_code is stored and no exception, it will t=
hrow=20
> sysem_error(ec)
>
> error_code() =E2=80=93 gives an ec [if exception is stored that is not de=
rived=20
> from system_error, ec is synthesized as described below)
>
> Exceptions derived from system_error has natural mapping to=20
> error_code, other exceptions can be mapped into=20
> =E2=80=9Csome-other-error-category=E2=80=9D with values matching all exis=
ting standard=20
> strongly typed exceptions and some 0xFFFFFFF other for all other=20
> exceptions.
>
Others have already requested this.
>
> >> Try to scale to more await expressions, and you will see why the if=20
> the else doesn't scales.
>
> intSomeApi(int* output1, int* output2) {
>
> do{
>
> *output1 =3D awaitfoo1();
>
> *output2 =3D awaitfoo2();
>
> returnSUCCESS;
>
> }
>
> catch(...) { // (*)
>
> returnERROR
> }
> }
>
> >> That means that the user would need to add split the function in=20
> two, one that do the recover and the other that uses await.
>
> Yes. You have foreseen my argument. J I can achieve the same effect=20
> with restructuring of the code.
>
> expected<Pair<int,int>> foo() {
>
> more computations here
>
> return { await foo1(), await foo2() };
>
> }
>
> intSomeApi(int* output1, int* output2) {
>
> if(autoresult =3D foo1()) {
>
> *output1 =3D result.first;
>
> *output2 =3D result.second;
>
> returnSUCCESS;
>
> }
>
> else{
>
> returnresult.error();
> }
> }
>
> My argument is that it is acceptable as it allows to separate error=20
> handling logic completely from business logic. Thus, I do not see the=20
> transformation above as limiting.
>
This seems to me cumbersome, and the same code returning future will be=20
completely different :(
>
> Now, I am weakly arguing against do-catch. I am not opposed to it.=20
> Just playing a devil=E2=80=99s advocate.
>
I see.
>
> >> So the error returned by f1() or f(2) would not be caught, it will=20
> be returned by the function f. This mean that try-catch and await=20
> don't work well together. The user would need to use .get() or=20
> .value() or whatever getter. But in this case the continuation style=20
> is broken as the program will block.
>
> I do not understand this. If a library writer defined a=20
> coroutine_promise for expected it needs to decide what error=20
> propagation mechanism it favors. He can chose to stop any exceptions=20
> in the body and resurface them as an exception stored in expected=20
> (define set_exception in the promise to stop all exceptions) and it=20
> can also choose to detect during unwrap whether an exception is stored=20
> in expected and call set_exceptions directly avoiding expensive=20
> exception propagation.
>
I have no problem on the internals of how to configure the type (at=20
least not yet). The problem is at the user of await level.
>
> It looks to me that seamless interactions with error propagating and=20
> exception propagating code is possible.
>
> >>The do-catch suggestion is a trial to take care of this issue.=20
> Surely not completely satisfying, but I think there is something to do=20
> with.
>
> It has a reasonable syntax. We can keep it in the back pocket and use=20
> it when someone demands for it
>
>
:(
> >>>>Not yet J.
>
> >> and now?
>
> Still neutral. I cannot find a compelling use case. All examples we=20
> had so far can be easily solved with minor restructuring of the code.
>
>
The case for futures needs a different solution, and I don't think=20
wrapping the result with expected is simple and friendly.
Doesn't matter, I don't think it is worth continuing this thread if we=20
have nothing to add.
Thanks for your feedback,
Vicente
--=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/.
--------------070304060207010309020608
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 13/11/14 22:58, Gor Nishanov a
=C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle25
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
..MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">>>
</span>I would expect that the type in catch (**) would be
exception_ptr if result has type expected<int>.<o:p></o:p><=
/p>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<p class=3D"MsoNormal">I surely hope not. <span
style=3D"font-family:Wingdings">J</span><o:p></o:p></p>
<p class=3D"MsoNormal">exception_ptr is a very poor mechanism for
dealing with errors that are not rare, since it requires throw
/ catch to unpack the result.</p>
</div>
</blockquote>
You are right. I wanted to say that the catch is not
expected<T>, but the stored exception. <br>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><o:p></o:p></p>
<p class=3D"MsoNormal">(Until compilers can recognize this pattern
and optimize it out).<o:p></o:p></p>
<p class=3D"MsoNormal">Ideally, I would like to have a
=E2=80=9CBetterThanExpected=E2=80=9D that stores a triple: a valu=
e or an
error_code and an (optional) exception.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<p class=3D"MsoNormal">Interface to expected would have:<o:p></o:p>=
</p>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<p class=3D"MsoNormal">exception() =E2=80=93 if error_code is store=
d and
no exception, it will throw sysem_error(ec)<o:p></o:p></p>
<p class=3D"MsoNormal">error_code() =E2=80=93 gives an ec [if excep=
tion is
stored that is not derived from system_error, ec is
synthesized as described below)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<p class=3D"MsoNormal">Exceptions derived from system_error has
natural mapping to error_code, other exceptions can be mapped
into =E2=80=9Csome-other-error-category=E2=80=9D with values matc=
hing all
existing standard strongly typed exceptions and some 0xFFFFFFF
other for all other exceptions.<o:p></o:p></p>
</div>
</blockquote>
Others have already requested this. <br>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">>> Try
to scale to more await expressions, and you will see why the
if the else doesn't scales.<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SomeApi(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">1,
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">2)
{</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">do</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
{</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">1
=3D </span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">await</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
foo1();</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">2
=3D </span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">await</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
foo2();</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SUCCESS;</span>
<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">catch</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
(...) {=C2=A0 // (*)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
ERROR</span>
<br>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}</span>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"><br>
}<br>
<br>
<o:p></o:p></span></p>
<p class=3D"MsoNormal">>> That means that the user would
need to add split the function in two, one that do the recover
and the other that uses await.
<br>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"><br>
</span>Yes. You have foreseen my argument. <span
style=3D"font-family:Wingdings">J</span> I can achieve the
same effect with restructuring of the code.<o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">expected<Pair<int,int>>
foo() {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0=C2=A0=C2=A0=C2=A0
more computations here<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">=C2=A0
=C2=A0=C2=A0=C2=A0return { await foo1(), await foo2() };=C2=A0
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">}<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SomeApi(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">1,
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">int</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">*
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">2)
{</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">if</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
(</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">auto</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
result =3D </span><span
style=3D"font-size:9.5pt;font-family:Consolas">foo1()) {</span>=
<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">1
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas"=
>result.first;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
*</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:gray;background:white;m=
so-highlight:white">output</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">2
=3D </span><span style=3D"font-size:9.5pt;font-family:Consolas"=
>result.second;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
SUCCESS;</span>
<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">else</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
{=C2=A0
</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
</span><span
style=3D"font-size:9.5pt;font-family:Consolas;color:blue;background:white;m=
so-highlight:white">return</span><span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">
</span><span style=3D"font-size:9.5pt;font-family:Consolas">resul=
t.error();</span>
<br>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white">=C2=A0=C2=A0=C2=A0
}</span>
<span
style=3D"font-size:9.5pt;font-family:Consolas;background:white;mso-highligh=
t:white"><br>
}<br>
<br>
</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">My
argument is that it is acceptable as it allows to separate
error handling logic completely from business logic. Thus, I
do not see the transformation above as limiting.</span></p>
</div>
</blockquote>
This seems to me cumbersome, and the same code returning future will
be completely different :(<br>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Now,
I am weakly arguing against do-catch. I am not opposed to
it. Just playing a devil=E2=80=99s advocate.</span></p>
</div>
</blockquote>
I see.<br>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal">>> So the error returned by f1() or
f(2) would not be caught, it will be returned by the function
f. This mean that try-catch and await don't work well
together. The user would need to use .get() or .value() or
whatever getter. But in this case the continuation style is
broken as the program will block.<br>
<br>
<span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">I
do not understand this. If a library writer defined a
coroutine_promise for expected it needs to decide what error
propagation mechanism it favors. He can chose to stop any
exceptions in the body and resurface them as an exception
stored in expected (define set_exception in the promise to
stop all exceptions) and it can also choose to detect during
unwrap whether an exception is stored in expected and call
set_exceptions directly avoiding expensive exception
propagation.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
</div>
</blockquote>
I have no problem on the internals of how to configure the type (at
least not yet). The problem is at the user of await level.<br>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">It
looks to me that seamless interactions with error
propagating and exception propagating code is possible.<o:p></o=
:p></span></p>
<p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p>
<p class=3D"MsoNormal">>>The do-catch suggestion is a trial
to take care of this issue. Surely not completely satisfying,
but I think there is something to do with.<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal">It has a reasonable syntax. We can keep it
in the back pocket and use it when someone demands for it<o:p></o=
:p></p>
<p class=3D"MsoNormal"><br>
</p>
</div>
</blockquote>
:(<br>
<br>
<blockquote
cite=3D"mid:78439933ad9c4347a5dd5c1c76e41238@BL2PR03MB337.namprd03.prod.out=
look.com"
type=3D"cite">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">
<span style=3D"color:windowtext">>>>> </span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">Not
yet
</span><span
style=3D"font-size:11.0pt;font-family:Wingdings;color:windowtex=
t">J</span><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:windowtext">.</span><o:p></o:p></p>
<p class=3D"MsoNormal">>> and now?<o:p></o:p></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><o:p>=C2=A0</o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D">Still
neutral. I cannot find a compelling use case. All examples
we had so far can be easily solved with minor restructuring
of the code.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span
style=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&=
quot;;color:#1F497D"><br>
</span></p>
</div>
</blockquote>
The case for futures needs a different solution, and I don't think
wrapping the result with expected is simple and friendly.<br>
Doesn't matter, I don't think it is worth continuing this thread if
we have nothing to add.<br>
<br>
Thanks for your feedback,<br>
Vicente<br>
<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--------------070304060207010309020608--
.
Author: Gor Nishanov <gornishanov@gmail.com>
Date: Fri, 14 Nov 2014 09:02:39 -0800 (PST)
Raw View
------=_Part_871_565549350.1415984559894
Content-Type: text/plain; charset=UTF-8
Vicente:
> Others have already requested this.
>
What was the outcome? Was it shot down? more work needed?
> This seems to me cumbersome, and the same code returning future will be
> completely different :(
>
Oh, don't despair. I think do-catch will fly, just under a different name.
I think we can use regular try-catch for that purpose. We just need to work
on compilers to make this pattern:
try {
.... throw bla; ...
} catch(x) {}
} catch(y) {}
} catch(z) {}
more efficient and not involve ABI based exception propagation but use
lighter weight mechanism.
I believe it will have identical shape to the proposed do-catch and similar
performance characteristics.
Now, if compiler vendors say that they need a syntactic sugar to help
understand where to apply the optimization you can suggest do-catch :-).
Essentially, I think that your do-catch proposal is awesome, but it is
somewhat unrelated to N4134. It can be used to improve error propagation in
general.
What do you think?
Gor
--
---
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/.
------=_Part_871_565549350.1415984559894
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Vicente:</div><div><br></div><div>
</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(2=
04, 204, 204); border-left-width: 1px; border-left-style: solid;"><div text=
=3D"#000000" bgcolor=3D"#FFFFFF">
=20
Others have already requested this. <br></div></blockquote><div><br></d=
iv><div>What was the outcome? Was it shot down? more work needed?</div><div=
>
</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(2=
04, 204, 204); border-left-width: 1px; border-left-style: solid;"><div text=
=3D"#000000" bgcolor=3D"#FFFFFF">
=20
This seems to me cumbersome, and the same code returning future will
be completely different :(<br></div></blockquote><div><br></div><div>Oh=
, don't despair. I think do-catch will fly, just under a different name.</d=
iv><div><br></div><div>I think we can use regular try-catch for that purpos=
e. We just need to work on compilers to make this pattern:</div><div><br></=
div><div>try {</div><div> .... throw bla; ...</div><div>} catch=
(x) {}</div><div><div>} catch(y) {}</div><div><div>} catch(z) {}</div></div=
></div><div><br></div><div>more efficient and not involve ABI based excepti=
on propagation but use lighter weight mechanism.</div><div><br></div><div>I=
believe it will have identical shape to the proposed do-catch and similar =
performance characteristics.</div><div><br></div><div>Now, if compiler vend=
ors say that they need a syntactic sugar to help understand where to apply =
the optimization you can suggest do-catch :-).</div><div><br></div><div>Ess=
entially, I think that your do-catch proposal is awesome, but it is somewha=
t unrelated to N4134. It can be used to improve error propagation in genera=
l.</div><div><br></div><div>What do you think?</div><div><br></div><div>Gor=
<br></div>
=20
</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_871_565549350.1415984559894--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 14 Nov 2014 19:21:38 +0100
Raw View
This is a multi-part message in MIME format.
--------------030408020704070209010904
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 14/11/14 18:02, Gor Nishanov a =C3=A9crit :
> Vicente:
>
> Others have already requested this.
>
>
> What was the outcome? Was it shot down? more work needed?
I would like to preserve the class as simple as possible. In my=20
prototype, there is a way to configure how the error behaves. I have not=20
proposed yet this configuration point because I'm not yet clear about=20
the interface.
The idea is to define what is required for an Error.
* make_error: How it can be built
* rethrow : states how this error is transformed to an exception
* make_error_from_current_exception
The default implementation are as follow
template <class E, class Error>
Error make_error(type<Error>, E e)
{
return e;
}
template <class Error>
void rethrow(Error e)
{
throw bad_expected_access<Error>(e);
}
// No valid default
template <class Error>
Error make_error_from_current_exception(type<Error>)
{
return E();
}
The overload for std::exception_ptr are
template <class Error>
exception_ptr make_error(type<exception_ptr>,Error e)
{
return make_exception_ptr(e);
}
inline void rethrow(exception_ptr e)
{
return rethrow_exception(e);
}
inline exception_ptr make_error_from_current_exception(type<exception_ptr>)
{
return current_exception();
}
If you want a specific error such as exception_ptr_or_error_code.
This class must be implicitly convertible from error_code and from=20
exception_ptr.
template <class Error>
exception_ptr make_error(type<exception_ptr_or_error_code>,Error e)
{
return exception_ptr_or_error_code(make_exception_ptr(e));
}
template <class Error>
exception_ptr make_error(type<exception_ptr_or_error_code>,error_code e)
{
return make_exception_ptr(system_error(e));
}
inline void rethrow(exception_ptr_or_error_code e)
{
return rethrow_exception(e.exception());
}
inline exception_ptr_or_error_code=20
make_error_from_current_exception(type<exception_ptr_or_error_code>)
{
return exception_ptr_or_error_code(current_exception());
}
In order to get the exception/error_code, the user needs to do
e.error().exception_ptr()
or
e.error().error_code()
> This seems to me cumbersome, and the same code returning future
> will be completely different :(
>
>
> Oh, don't despair. I think do-catch will fly, just under a different name=
..
>
> I think we can use regular try-catch for that purpose. We just need to=20
> work on compilers to make this pattern:
>
> try {
> .... throw bla; ...
> } catch(x) {}
> } catch(y) {}
> } catch(z) {}
>
> more efficient and not involve ABI based exception propagation but use=20
> lighter weight mechanism.
>
> I believe it will have identical shape to the proposed do-catch and=20
> similar performance characteristics.
>
How it it that we don't have this already?
> Now, if compiler vendors say that they need a syntactic sugar to help=20
> understand where to apply the optimization you can suggest do-catch :-).
I'm not a compiler guy, but I suspect that some syntactic sugar help=20
would be appreciated.
>
> Essentially, I think that your do-catch proposal is awesome, but it is=20
> somewhat unrelated to N4134. It can be used to improve error=20
> propagation in general.
>
> What do you think?
>
I believe that it is somewhat related to N4134 ;-). I can live with=20
N4134 without do-catch but I would prefer to have a recovery propagation=20
that don't use exceptions. std::experimental::expected is expected (pun=20
intended) in environments without exceptions.
Vicente
--=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/.
--------------030408020704070209010904
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 14/11/14 18:02, Gor Nishanov a
=C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:1921ea0d-1a25-497a-badf-c811395a887b@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">
<div>Vicente:</div>
<div><br>
</div>
<div>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </div>
<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px
0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204,
204); border-left-width: 1px; border-left-style: solid;">
<div text=3D"#000000" bgcolor=3D"#FFFFFF"> Others have already
requested this. <br>
</div>
</blockquote>
<div><br>
</div>
<div>What was the outcome? Was it shot down? more work needed?</div=
>
</div>
</blockquote>
I would like to preserve the class as simple as possible. In my
prototype, there is a way to configure how the error behaves. I have
not proposed yet this configuration point because I'm not yet clear
about the interface. <br>
The idea is to define what is required for an Error. <br>
* make_error: How it can be built<br>
* rethrow : states how this error is transformed to an exception<br>
* make_error_from_current_exception<br>
<br>
The default implementation are as follow<br>
<br>
template <class E, class Error><br>
Error make_error(type<Error>, E e)<br>
{<br>
=C2=A0 return e;<br>
}<br>
template <class Error><br>
void rethrow(Error e)<br>
{<br>
=C2=A0 throw bad_expected_access<Error>(e);<br>
}<br>
<br>
// No valid default<br>
template <class Error><br>
Error make_error_from_current_exception(type<Error>)<br>
{<br>
=C2=A0 return E();<br>
}<br>
<br>
The overload for std::exception_ptr are<br>
<br>
template <class Error><br>
exception_ptr make_error(type<exception_ptr>,Error e)<br>
{<br>
=C2=A0 return make_exception_ptr(e);<br>
}<br>
inline void rethrow(exception_ptr e)<br>
{<br>
=C2=A0 return rethrow_exception(e);<br>
}<br>
inline exception_ptr
make_error_from_current_exception(type<exception_ptr>)<br>
{<br>
=C2=A0 return current_exception();<br>
}<br>
<br>
If you want a specific error such as exception_ptr_or_error_code.<br>
This class must be implicitly convertible from error_code and from
exception_ptr.<br>
<br>
template <class Error><br>
exception_ptr
make_error(type<exception_ptr_or_error_code>,Error e)<br>
{<br>
=C2=A0 return exception_ptr_or_error_code(make_exception_ptr(e));<br>
}<br>
template <class Error><br>
exception_ptr
make_error(type<exception_ptr_or_error_code>,error_code e)<br>
{<br>
=C2=A0 return make_exception_ptr(system_error(e));<br>
}<br>
inline void rethrow(exception_ptr_or_error_code e)<br>
{<br>
=C2=A0 return rethrow_exception(e.exception());<br>
}<br>
inline exception_ptr_or_error_code
make_error_from_current_exception(type<exception_ptr_or_error_code>)<=
br>
{<br>
=C2=A0 return exception_ptr_or_error_code(current_exception());<br>
}<br>
<br>
In order to get the exception/error_code, the user needs to do<br>
<br>
e.error().exception_ptr()<br>
<br>
or<br>
<br>
e.error().error_code()<br>
<br>
<br>
<br>
<blockquote
cite=3D"mid:1921ea0d-1a25-497a-badf-c811395a887b@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">
<div>=C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </div>
<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px
0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204,
204); border-left-width: 1px; border-left-style: solid;">
<div text=3D"#000000" bgcolor=3D"#FFFFFF"> This seems to me
cumbersome, and the same code returning future will be
completely different :(<br>
</div>
</blockquote>
<div><br>
</div>
<div>Oh, don't despair. I think do-catch will fly, just under a
different name.</div>
<div><br>
</div>
<div>I think we can use regular try-catch for that purpose. We
just need to work on compilers to make this pattern:</div>
<div><br>
</div>
<div>try {</div>
<div>=C2=A0=C2=A0 .... throw bla; ...</div>
<div>} catch(x) {}</div>
<div>
<div>} catch(y) {}</div>
<div>
<div>} catch(z) {}</div>
</div>
</div>
<div><br>
</div>
<div>more efficient and not involve ABI based exception
propagation but use lighter weight mechanism.</div>
<div><br>
</div>
<div>I believe it will have identical shape to the proposed
do-catch and similar performance characteristics.</div>
<div><br>
</div>
</div>
</blockquote>
How it it that we don't have this already?<br>
<blockquote
cite=3D"mid:1921ea0d-1a25-497a-badf-c811395a887b@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">
<div>Now, if compiler vendors say that they need a syntactic
sugar to help understand where to apply the optimization you
can suggest do-catch :-).</div>
</div>
</blockquote>
I'm not=C2=A0 a compiler guy, but I suspect that some syntactic sugar
help would be appreciated.<br>
<blockquote
cite=3D"mid:1921ea0d-1a25-497a-badf-c811395a887b@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">
<div><br>
</div>
<div>Essentially, I think that your do-catch proposal is
awesome, but it is somewhat unrelated to N4134. It can be used
to improve error propagation in general.</div>
<div><br>
</div>
<div>What do you think?</div>
<div><br>
</div>
</div>
</blockquote>
I believe that it is somewhat related to N4134 ;-). I can live with
N4134 without do-catch but I would prefer to have a recovery
propagation that don't use exceptions. std::experimental::expected
is expected (pun intended) in environments without exceptions.<br>
<br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--------------030408020704070209010904--
.
Author: Gor Nishanov <gornishanov@gmail.com>
Date: Fri, 14 Nov 2014 17:08:20 -0800 (PST)
Raw View
------=_Part_1184_115348147.1416013700722
Content-Type: multipart/alternative;
boundary="----=_Part_1185_1626057035.1416013700722"
------=_Part_1185_1626057035.1416013700722
Content-Type: text/plain; charset=UTF-8
Vicente:
On Friday, November 14, 2014 10:21:40 AM UTC-8, Vicente J. Botet Escriba
wrote:
>
> Gor: I believe it will have identical shape to the proposed do-catch and
> similar performance characteristics.
>
> How it it that we don't have this already?
>
Those who care about perf do not use exceptions on the important code path.
They use functions that are either "no-fail" or have some way to do an
error code (boost::file_system style or expected<T> or some other way).
Handling errors in such programs is not painful enough to demand better
exceptions.
Therefore, few people clamor for better exceptions.
> I'm not a compiler guy, but I suspect that some syntactic sugar help
> would be appreciated.
>
I am not a compiler guy either. I just joined the team working in the OS
division before.
My feel is that making exceptions faster / introducing do-catch is
significant undertaking and need to be weighted with respect to other cool
things we can be working on and whether the pain of not having do-catch is
strong enough. [It never rose to a high level for me, or I would be the
first inline advocating for it :-)]
> std::experimental::expected is expected (pun intended) in environments
> without exceptions.
>
Oh, I want a good expected<T> badly. Probably
template <typename T, typename E = std::exception_ptr> struct expected;
so that we don't drag exception machinery in the environments where it is
undersirable or unavailable.
I might even favor this one even more:
template <typename T, typename E = std::error_code> struct expected;
Gor
P.S.
I think that N4134 can give extra boost for people to become more agreeable
to having expected<T>, we can enlist embedded guys and google guys as
supporters, since neither of them can use exceptions :-)
--
---
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/.
------=_Part_1185_1626057035.1416013700722
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Vicente:<br><br>On Friday, November 14, 2014 10:21:40=
AM UTC-8, Vicente J. Botet Escriba wrote:</div><blockquote class=3D"gmail_=
quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-c=
olor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;=
">
=20
=20
=20
<div text=3D"#000000" bgcolor=3D"#FFFFFF">
<div>Gor: I believe it will have identical shape to the =
proposed
do-catch and similar performance characteristics.</div>
<div><br>
</div>
=20
=20
How it it that we don't have this already?<br></div></blockquote><div><=
br></div><div>Those who care about perf do not use exceptions on the import=
ant code path. They use functions that are either "no-fail" or have some wa=
y to do an error code (boost::file_system style or expected<T> or som=
e other way). </div><div><br></div><div>Handling errors in such programs is=
not painful enough to demand better exceptions.</div><div>Therefore, few p=
eople clamor for better exceptions.</div><div> </div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div text=3D"#000000" bgcolor=3D"#FFFFFF">
=20
=20
I'm not a compiler guy, but I suspect that some syntactic sugar
help would be appreciated.<br></div></blockquote><div><br></div><div>I =
am not a compiler guy either. I just joined the team working in the OS divi=
sion before.</div><div>My feel is that making exceptions faster / introduci=
ng do-catch is significant undertaking and need to be weighted with respect=
to other cool things we can be working on and whether the pain of not havi=
ng do-catch is strong enough. [It never rose to a high level for me, or I w=
ould be the first inline advocating for it :-)]</div><div> </div><bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-le=
ft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bor=
der-left-style: solid;"><div text=3D"#000000" bgcolor=3D"#FFFFFF">std::expe=
rimental::expected
is expected (pun intended) in environments without exceptions.<br></div=
></blockquote><div><br></div><div>Oh, I want a good expected<T=
> badly. Probably</div><div><br></div><div>template <typename T=
, typename E =3D std::exception_ptr> struct expected; </div><div><br></d=
iv><div>so that we don't drag exception machinery in the environments where=
it is undersirable or unavailable.</div><div><br></div><div>I might even f=
avor this one even more:</div><div><br></div><div><div>template <typenam=
e T, typename E =3D std::error_code> struct expected; </div> </div>=
<div>Gor</div><div><br></div><div>P.S.</div><div><br></div><div>I think tha=
t N4134 can give extra boost for people to become more agreeable to having =
expected<T>, we can enlist embedded guys and google guys as supporter=
s, since neither of them can use exceptions :-)</div><div><br></div>
=20
</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1185_1626057035.1416013700722--
------=_Part_1184_115348147.1416013700722--
.