Topic: Comment on n4233 - status_value and expected
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 19 Oct 2014 10:03:24 +0200
Raw View
This is a multi-part message in MIME format.
--------------080101090103040700090802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi,
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html
propose a status_value template class that IMO could corresponds to
expected with some cosmetic functions. I have not found a case where the
value is set with an status different from success. Could you point to
where it is needed to store a Value and an Status different from success?
n4233 status_value is no default constructible, while expected is (if
Value is). Do we need to restrict this default initialization?
Next follows two expected based status_value classes depending on
whether we want to been able to store an Exception in addition of a
Value or an Status.
Option 1
template <class Status, class Value>
using status_value = expected<Value, Status> ;
Option 2
template <class Status, class Value>
using status_value = expected<expected<Value, Status>> ;
Next follows equivalent initializations
|
||(||n4233)
|
status_value sv1(st1);
status_value sv2(success, value);
||(expected based option 1)
|
||status_value sv1(make_unexpected(st1));
status_value sv2(value);
(expected based option 2)
|
||status_value sv1(expected<Value, Status>(unexpected(st1)));
status_value sv2(expected<Value, Status>(value));
Next follows equivalent usage
|
(||n4233)
||Value e = q.value_pop().value();
|||(expected based option 1)
|
|Value e = q.value_pop().value();
|
(expected based option 2)
|
|Value e = q.value_pop().value().value();
==============
|
|(||n4233)
|
||auto sv = q.try_pop();
if ( sv.status() == queue_op_status::success )
do_something_with(sv.value());
else
do_something_else_with(sv.status());|
|
|(expected based option 1)|
||
|auto sv = q.try_pop();
if ( sv )
do_something_with(sv.value());
else
do_something_else_with(sv.error());|
|
|||(expected based option 2)|
||
|auto sv = q.try_pop();
if ( sv.value() )
do_something_with(sv.value().value());
else
do_something_else_with(sv.value().error());|
|
|
(expected based option 2)|
||
|auto sv = q.try_pop();
if ( sv.value() )
do_something_with(sv.value().value());
else
do_something_else_with(sv.value().error());|
|
|
|==============
|
||(||n4233)
|
|||if ( auto sv = q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.status());|
|||(expected based option 1)
|
|if ( auto sv = q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.error());||
|
(expected based option 2)
|
|if ( auto sv = q.try_pop().value() )
do_something_with(*sv);
else
do_something_else_with(sv.error());|
Vicente
--
---
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/.
--------------080101090103040700090802
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
Hi,<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html</a>
propose a status_value template class that IMO could corresponds to
expected with some cosmetic functions. I have not found a case where
the value is set with an status different from success. Could you
point to where it is needed to store a Value and an Status different
from success?<br>
<br>
n4233 status_value is no default constructible, while expected is
(if Value is). Do we need to restrict this default initialization?<br>
<br>
<br>
Next follows two expected based status_value classes depending on
whether we want to been able to store an Exception in addition of a
Value or an Status.<br>
<br>
Option 1<br>
<br>
template <class Status, class Value><br>
<font size="+1">using status_value = expected<Value, Status> </font>;<br>
<br>
Option 2<br>
template <class Status, class Value><br>
<font size="+1">using status_value = expected<expected<Value,
Status>> </font>;<br>
<br>
<br>
Next follows equivalent initializations<br>
<pre><code>
</code><font size="+1"><code>(</code><code>n4233)
</code>
status_value sv1(st1);</font>
<font size="+1">status_value sv2(success, value);</font>
<code><code>(expected based option 1)
</code>
<code></code><font size="+1">status_value sv1(make_unexpected(st1));</font>
<font size="+1">status_value sv2(</font><font size="+1"><font size="+1">value</font>);</font>
(expected based option 2)
</code>
<code></code><font size="+1">status_value sv1(expected<Value, Status>(unexpected(st1)));</font>
<font size="+1">status_value sv2(</font><font size="+1"><font size="+1">expected<Value, Status>(value)</font>);</font>
</pre>
Next follows equivalent usage<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<pre><code>
(</code><code>n4233)
</code><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><code>Value e = q.value_pop().value();
</code><code><code>(expected based option 1)
</code>
<code>Value e = q.value_pop().value();
</code>
(expected based option 2)
</code></pre>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<pre><code>Value e = q.value_pop().value().value();
==============
</code><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<code>(</code><code>n4233)
</code>
<code><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><code>auto sv = q.try_pop();
if ( sv.status() == queue_op_status::success )
do_something_with(sv.value());
else
do_something_else_with(sv.status());</code>
</code>
<code>(expected based option 1)</code>
<code></code>
<code>auto sv = q.try_pop();
if ( sv )
do_something_with(sv.value());
else
do_something_else_with(sv.error());</code>
<code>
</code><code><code>(expected based option 2)</code>
<code></code>
<code>auto sv = q.try_pop();
if ( sv.value() )
do_something_with(sv.value().value());
else
do_something_else_with(sv.value().error());</code>
<code>
</code>
(expected based option 2)</code>
<code></code>
<code>auto sv = q.try_pop();
if ( sv.value() )
do_something_with(sv.value().value());
else
do_something_else_with(sv.value().error());</code>
<code>
</code>
<code>==============
</code>
<code><code>(</code><code>n4233)
</code>
</code><code><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><code>if ( auto sv = q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.status());</code>
</code><code><code>(expected based option 1)
</code>
<code>if ( auto sv = q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.error());</code></code>
<code>
(expected based option 2)
</code>
<code>if ( auto sv = q.try_pop().value() )
do_something_with(*sv);
else
do_something_else_with(sv.error());</code><pre></pre>
Vicente
</pre>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
--------------080101090103040700090802--
.
Author: Gor Nishanov <gornishanov@gmail.com>
Date: Fri, 14 Nov 2014 17:44:37 -0800 (PST)
Raw View
------=_Part_1091_1754537806.1416015877062
Content-Type: text/plain; charset=UTF-8
Vicente:
Similar questions have been raised during N4233 discussion. You can read
the notes at the wiki:
http://wiki.edg.com/twiki/bin/view/Wg21urbana-champaign/N4233
The conclusion was:
Person A: Seems like a certain amount of brainstorming has been going on. I
think it would be a good idea to survey existing practice and enumerate the
pros and cons of the solution space. We should be looking for existing
practice, if it will do the job. If nothing does, we ought to have a
document which says that and explains it."
Person B: But if we can make the FS interface work, it would be a good
thing to go down that path just to see what it would look like.
Person C: : The question I wanted to answer was whether or not we actually
need to return both. I'd be willing to live with the either/or situation.
But with this approach, it doesn't matter because you get both anyway. So
at least I think we can formulate a question for LWG at this point.
Person D: EWG needs to comment on all approaches which report errors via
non-exceptions.
On Sunday, October 19, 2014 1:03:27 AM UTC-7, Vicente J. Botet Escriba
wrote:
>
> Hi,
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html
> propose a status_value template class that IMO could corresponds to
> expected with some cosmetic functions. I have not found a case where the
> value is set with an status different from success. Could you point to
> where it is needed to store a Value and an Status different from success?
>
> n4233 status_value is no default constructible, while expected is (if
> Value is). Do we need to restrict this default initialization?
>
>
> Next follows two expected based status_value classes depending on whether
> we want to been able to store an Exception in addition of a Value or an
> Status.
>
> Option 1
>
> template <class Status, class Value>
> using status_value = expected<Value, Status> ;
>
> Option 2
> template <class Status, class Value>
> using status_value = expected<expected<Value, Status>> ;
>
>
> Next follows equivalent initializations
>
> (n4233)
> status_value sv1(st1);status_value sv2(success, value);
>
> (expected based option 1)status_value sv1(make_unexpected(st1));status_value sv2(value);
>
> (expected based option 2)status_value sv1(expected<Value, Status>(unexpected(st1)));status_value sv2(expected<Value, Status>(value));
>
> Next follows equivalent usage
>
>
> (n4233)
> Value e = q.value_pop().value();
> (expected based option 1)Value e = q.value_pop().value();
> (expected based option 2)
>
> Value e = q.value_pop().value().value();
>
>
> ==============(n4233)auto sv = q.try_pop();
> if ( sv.status() == queue_op_status::success )
> do_something_with(sv.value());
> else
> do_something_else_with(sv.status());
> (expected based option 1)auto sv = q.try_pop();
> if ( sv )
> do_something_with(sv.value());
> else
> do_something_else_with(sv.error());(expected based option 2)auto sv = q.try_pop();
> if ( sv.value() )
> do_something_with(sv.value().value());
> else
> do_something_else_with(sv.value().error());
> (expected based option 2)auto sv = q.try_pop();
> if ( sv.value() )
> do_something_with(sv.value().value());
> else
> do_something_else_with(sv.value().error());==============(n4233)if ( auto sv = q.try_pop() )
> do_something_with(*sv);
> else
> do_something_else_with(sv.status());
> (expected based option 1)if ( auto sv = q.try_pop() )
> do_something_with(*sv);
> else
> do_something_else_with(sv.error());
>
> (expected based option 2)if ( auto sv = q.try_pop().value() )
> do_something_with(*sv);
> else
> do_something_else_with(sv.error());
>
> Vicente
>
>
--
---
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_1091_1754537806.1416015877062
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Vicente:</div><div><br></div><div>Similar questions h=
ave been raised during N4233 discussion. You can read the notes at the wiki=
: <a href=3D"http://wiki.edg.com/twiki/bin/view/Wg21urbana-champaign/N4233"=
>http://wiki.edg.com/twiki/bin/view/Wg21urbana-champaign/N4233</a></div><di=
v><br></div><div>The conclusion was:</div><div><br></div><div>Person A: See=
ms like a certain amount of brainstorming has been going on. I think it wou=
ld be a good idea to survey existing practice and enumerate the pros and co=
ns of the solution space. We should be looking for existing practice, if it=
will do the job. If nothing does, we ought to have a document which says t=
hat and explains it."</div><div><br></div><div>Person B: But if we can make=
the FS interface work, it would be a good thing to go down that path just =
to see what it would look like. <br><br><p>Person C: : The question I wante=
d to answer was whether or not we actually need to return both. I'd be will=
ing to live with the either/or situation. But with this approach, it doesn'=
t matter because you get both anyway. So at least I think we can formulate =
a question for LWG at this point. <p>Person D: EWG needs to comment on all =
approaches which report errors via non-exceptions.</p><p><br>On Sunday, Oct=
ober 19, 2014 1:03:27 AM UTC-7, Vicente J. Botet Escriba wrote:</p></div><b=
lockquote 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;">
=20
=20
=20
<div text=3D"#000000" bgcolor=3D"#FFFFFF">
<br>
Hi,<br>
<br>
<a onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F=
%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4233.htm=
l\46sa\75D\46sntz\0751\46usg\75AFQjCNEE5ItEabB73NcqHbI1oVkiaNTMMw';return t=
rue;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fww=
w.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4233.html\46s=
a\75D\46sntz\0751\46usg\75AFQjCNEE5ItEabB73NcqHbI1oVkiaNTMMw';return true;"=
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html=
" target=3D"_blank">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers=
/2014/<wbr>n4233.html</a>
propose a status_value template class that IMO could corresponds to
expected with some cosmetic functions. I have not found a case where
the value is set with an status different from success. Could you
point to where it is needed to store a Value and an Status different
from success?<br>
<br>
n4233 status_value is no default constructible, while expected is
(if Value is). Do we need to restrict this default initialization?<br>
<br>
<br>
Next follows two expected based status_value classes depending on
whether we want to been able to store an Exception in addition of a
Value or an Status.<br>
<br>
Option 1<br>
<br>
template <class Status, class Value><br>
<font size=3D"+1">using status_value =3D expected<Value, Status> =
</font>;<br>
<br>
Option 2<br>
template <class Status, class Value><br>
<font size=3D"+1">using status_value =3D expected<expected<Value,
Status>> </font>;<br>
<br>
<br>
Next follows equivalent initializations<br>
<pre><code>
</code><font size=3D"+1"><code>(</code><code>n4233)
</code>
status_value sv1(st1);</font>
<font size=3D"+1">status_value sv2(success, value);</font>
<code><code>(expected based option 1)
</code>
<code></code><font size=3D"+1">status_value sv1(make_unexpected(st1));</fon=
t>
<font size=3D"+1">status_value sv2(</font><font size=3D"+1"><font size=3D"+=
1">value</font>);</font>
(expected based option 2)
</code>
<code></code><font size=3D"+1">status_value sv1(expected<Value, Status&g=
t;(unexpected(st1)));</font>
<font size=3D"+1">status_value sv2(</font><font size=3D"+1"><font size=3D"+=
1">expected<Value, Status>(value)</font>);</font>
</pre>
Next follows equivalent usage<br>
=20
<pre><code>
(</code><code>n4233)
</code><code>Value e =3D q.value_pop().value();
</code><code><code>(expected based option 1)
</code>
<code>Value e =3D q.value_pop().value();
</code>
(expected based option 2)
</code></pre>
=20
<pre><code>Value e =3D q.value_pop().value().value();
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
</code>
<code>(</code><code>n4233)
</code>
<code><code>auto sv =3D q.try_pop();
if ( sv.status() =3D=3D queue_op_status::success )
do_something_with(sv.value());
else
do_something_else_with(sv.<wbr>status());</code>
</code>
<code>(expected based option 1)</code>
<code></code>
<code>auto sv =3D q.try_pop();
if ( sv )
do_something_with(sv.value());
else
do_something_else_with(sv.<wbr>error());</code>
<code>
</code><code><code>(expected based option 2)</code>
<code></code>
<code>auto sv =3D q.try_pop();
if ( sv.value() )
do_something_with(sv.value().<wbr>value());
else
do_something_else_with(sv.<wbr>value().error());</code>
<code>
</code>
(expected based option 2)</code>
<code></code>
<code>auto sv =3D q.try_pop();
if ( sv.value() )
do_something_with(sv.value().<wbr>value());
else
do_something_else_with(sv.<wbr>value().error());</code>
<code>
</code>
<code>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
</code>
<code><code>(</code><code>n4233)
</code>
</code><code><code>if ( auto sv =3D q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.<wbr>status());</code>
</code><code><code>(expected based option 1)
</code>
<code>if ( auto sv =3D q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.<wbr>error());</code></code>
<code>
(expected based option 2)
</code>
<code>if ( auto sv =3D q.try_pop().value() )
do_something_with(*sv);
else
do_something_else_with(sv.<wbr>error());</code><pre></pre>
Vicente
</pre>
</div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_1091_1754537806.1416015877062--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 21 Nov 2014 00:55:31 +0100
Raw View
This is a multi-part message in MIME format.
--------------000402060306060101020500
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Hi,
I guess I'm the close to the Person C.
To person B I will say that: I have not seen yet a case where the value=20
and the status are needed. So the question is: what are the use cases=20
status_value is good for? I'm not saying that status_value could not be=20
appropriated in some cases, just that it is not needed for the=20
concurrent queues.
I see the following approaches
EC * using a specific error_code parameter by reference to report the=20
error (Filesystem)
E * using expected to wrap the value or the error
SV * using status_value to wrap the value and the status (some of them=20
meaning failure other success).
.... others
EC and SV return both the value and the error.
E can only report one of them.
EC doesnt compose well.
E and SV compose well
E identifies clearly the error cases and can be seen a monad error
SV doesn't identifies which status mean failures and which ones mean=20
success, and so it would need an additional function to make it possible=20
to see it as a monad error.
With E we can propagate and recovery from errors easily. SV makes this a=20
little bit more difficult.
SV can be simulated with E. If we want to return an error or a value=20
and a success status with expected we can just use
expected<pair<T, Success>>, Failure>.
Here the meaning is clear. You don't need to build an artificial T when=20
there is an error.
In order to simulate expected<T,E> with status_value we need
status_value<E+success, optional<T>>.
Where E+success means the type E extended with a success value.
There are surely more differences, so if you want to help, I'm open to=20
work with those that consider an alternative is better that the others.=20
To those that interested, please, contact me so that we can co-author a=20
paper.
To all, we need your help to identify concrete use case for those you=20
want to report errors via non-exceptions.
Best,
Vicente
Le 15/11/14 02:44, Gor Nishanov a =C3=A9crit :
> Vicente:
>
> Similar questions have been raised during N4233 discussion. You can=20
> read the notes at the wiki:=20
> http://wiki.edg.com/twiki/bin/view/Wg21urbana-champaign/N4233
>
> The conclusion was:
>
> Person A: Seems like a certain amount of brainstorming has been going=20
> on. I think it would be a good idea to survey existing practice and=20
> enumerate the pros and cons of the solution space. We should be=20
> looking for existing practice, if it will do the job. If nothing does,=20
> we ought to have a document which says that and explains it."
>
> Person B: But if we can make the FS interface work, it would be a good=20
> thing to go down that path just to see what it would look like.
>
> Person C: : The question I wanted to answer was whether or not we=20
> actually need to return both. I'd be willing to live with the=20
> either/or situation. But with this approach, it doesn't matter because=20
> you get both anyway. So at least I think we can formulate a question=20
> for LWG at this point.
>
> Person D: EWG needs to comment on all approaches which report errors=20
> via non-exceptions.
>
>
> On Sunday, October 19, 2014 1:03:27 AM UTC-7, Vicente J. Botet Escriba=20
> wrote:
>
>
> Hi,
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html>
> propose a status_value template class that IMO could corresponds
> to expected with some cosmetic functions. I have not found a case
> where the value is set with an status different from success.
> Could you point to where it is needed to store a Value and an
> Status different from success?
>
> n4233 status_value is no default constructible, while expected is
> (if Value is). Do we need to restrict this default initialization?
>
>
> Next follows two expected based status_value classes depending on
> whether we want to been able to store an Exception in addition of
> a Value or an Status.
>
> Option 1
>
> template <class Status, class Value>
> using status_value =3D expected<Value, Status> ;
>
> Option 2
> template <class Status, class Value>
> using status_value =3D expected<expected<Value, Status>> ;
>
>
> Next follows equivalent initializations
>
> |
> ||(||n4233)
> |
> status_value sv1(st1);
> status_value sv2(success, value);
>
>
> ||(expected based option 1)
> |
> ||status_value sv1(make_unexpected(st1));
> status_value sv2(value);
>
> (expected based option 2)
> |
> ||status_value sv1(expected<Value, Status>(unexpected(st1)));
> status_value sv2(expected<Value, Status>(value));
>
> Next follows equivalent usage
>
> |
> (||n4233)
>
> ||Value e =3D q.value_pop().value();
>
> |||(expected based option 1)
> |
> |Value e =3D q.value_pop().value();
> |
> (expected based option 2)
> |
>
> |Value e =3D q.value_pop().value().value();
>
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> |
> |(||n4233)
> |
> ||auto sv =3D q.try_pop();
> if ( sv.status() =3D=3D queue_op_status::success )
> do_something_with(sv.value());
> else
> do_something_else_with(sv.status());|
>
> |
> |(expected based option 1)|
> ||
> |auto sv =3D q.try_pop();
> if ( sv )
> do_something_with(sv.value());
> else
> do_something_else_with(sv.error());|
> |
> |||(expected based option 2)|
> ||
> |auto sv =3D q.try_pop();
> if ( sv.value() )
> do_something_with(sv.value().value());
> else
> do_something_else_with(sv.value().error());|
> |
> |
> (expected based option 2)|
> ||
> |auto sv =3D q.try_pop();
> if ( sv.value() )
> do_something_with(sv.value().value());
> else
> do_something_else_with(sv.value().error());|
> |
> |
> |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> |
> ||(||n4233)
> |
> |||if ( auto sv =3D q.try_pop() )
> do_something_with(*sv);
> else
> do_something_else_with(sv.status());|
>
> |||(expected based option 1)
> |
> |if ( auto sv =3D q.try_pop() )
> do_something_with(*sv);
> else
> do_something_else_with(sv.error());||
>
> |
> (expected based option 2)
> |
> |if ( auto sv =3D q.try_pop().value() )
> do_something_with(*sv);
> else
> do_something_else_with(sv.error());|
>
> Vicente
>
> --=20
>
> ---
> You received this message because you are subscribed to the Google=20
> Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send=20
> an email to std-proposals+unsubscribe@isocpp.org=20
> <mailto:std-proposals+unsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org=20
> <mailto:std-proposals@isocpp.org>.
> Visit this group at=20
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--------------000402060306060101020500
Content-Type: text/html; charset=UTF-8
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
I guess I'm the close to the Person C.<br>
<br>
To person B I will say that: I have not seen yet a case where the
value and the status are needed. So the question is: what are the
use cases status_value is good for? I'm not saying that
status_value could not be appropriated in some cases, just that it
is not needed for the concurrent queues.<br>
<br>
I see the following approaches <br>
<br>
EC * using a specific error_code parameter by reference to report
the error (Filesystem)<br>
E * using expected to wrap the value or the error<br>
SV * using status_value to wrap the value and the status (some of
them meaning failure other success).<br>
... others<br>
<br>
<br>
EC and SV return both the value and the error.<br>
E can only report one of them.<br>
<br>
EC doesnt compose well.<br>
E and SV compose well <br>
<br>
E identifies clearly the error cases and can be seen a monad
error<br>
SV doesn't identifies which status mean failures and which ones
mean success, and so it would need an additional function to make
it possible to see it as a monad error.<br>
<br>
With E we can propagate and recovery from errors easily. SV makes
this a little bit more difficult.<br>
<br>
SV can be simulated with E. If we want to return an error or a
value and a success status with expected we can just use<br>
expected<pair<T, Success>>, Failure>.<br>
<br>
Here the meaning is clear. You don't need to build an artificial T
when there is an error.<br>
<br>
In order to simulate expected<T,E> with status_value we need<br>
<br>
status_value<E+success, optional<T>>.<br>
<br>
Where E+success means the type E extended with a success value.<br>
<br>
There are surely more differences, so if you want to help, I'm
open to work with those that consider an alternative is better
that the others. To those that interested, please, contact me so
that we can co-author a paper.<br>
<br>
To all, we need your help to identify concrete use case for those
you want to report errors via non-exceptions.<br>
<br>
Best,<br>
Vicente<br>
<br>
<br>
Le 15/11/14 02:44, Gor Nishanov a écrit :<br>
</div>
<blockquote
cite="mid:0ad1f342-5fb7-405e-a353-6116565b1011@isocpp.org"
type="cite">
<div dir="ltr">
<div>Vicente:</div>
<div><br>
</div>
<div>Similar questions have been raised during N4233 discussion.
You can read the notes at the wiki: <a moz-do-not-send="true"
href="http://wiki.edg.com/twiki/bin/view/Wg21urbana-champaign/N4233">http://wiki.edg.com/twiki/bin/view/Wg21urbana-champaign/N4233</a></div>
<div><br>
</div>
<div>The conclusion was:</div>
<div><br>
</div>
<div>Person A: Seems like a certain amount of brainstorming has
been going on. I think it would be a good idea to survey
existing practice and enumerate the pros and cons of the
solution space. We should be looking for existing practice, if
it will do the job. If nothing does, we ought to have a
document which says that and explains it."</div>
<div><br>
</div>
<div>Person B: But if we can make the FS interface work, it
would be a good thing to go down that path just to see what it
would look like. <br>
<br>
<p>Person C: : The question I wanted to answer was whether or
not we actually need to return both. I'd be willing to live
with the either/or situation. But with this approach, it
doesn't matter because you get both anyway. So at least I
think we can formulate a question for LWG at this point. </p>
<p>Person D: EWG needs to comment on all approaches which
report errors via non-exceptions.</p>
<p><br>
On Sunday, October 19, 2014 1:03:27 AM UTC-7, Vicente J.
Botet Escriba wrote:</p>
</div>
<blockquote class="gmail_quote" style="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="#000000" bgcolor="#FFFFFF"> <br>
Hi,<br>
<br>
<a moz-do-not-send="true"
onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4233.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEE5ItEabB73NcqHbI1oVkiaNTMMw';return
true;"
onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4233.html\46sa\75D\46sntz\0751\46usg\75AFQjCNEE5ItEabB73NcqHbI1oVkiaNTMMw';return
true;"
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4233.html"
target="_blank">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2014/<wbr>n4233.html</a>
propose a status_value template class that IMO could
corresponds to expected with some cosmetic functions. I have
not found a case where the value is set with an status
different from success. Could you point to where it is
needed to store a Value and an Status different from
success?<br>
<br>
n4233 status_value is no default constructible, while
expected is (if Value is). Do we need to restrict this
default initialization?<br>
<br>
<br>
Next follows two expected based status_value classes
depending on whether we want to been able to store an
Exception in addition of a Value or an Status.<br>
<br>
Option 1<br>
<br>
template <class Status, class Value><br>
<font size="+1">using status_value = expected<Value,
Status> </font>;<br>
<br>
Option 2<br>
template <class Status, class Value><br>
<font size="+1">using status_value =
expected<expected<Value, Status>> </font>;<br>
<br>
<br>
Next follows equivalent initializations<br>
<pre><code>
</code><font size="+1"><code>(</code><code>n4233)
</code>
status_value sv1(st1);</font>
<font size="+1">status_value sv2(success, value);</font>
<code><code>(expected based option 1)
</code>
<code></code><font size="+1">status_value sv1(make_unexpected(st1));</font>
<font size="+1">status_value sv2(</font><font size="+1"><font size="+1">value</font>);</font>
(expected based option 2)
</code>
<code></code><font size="+1">status_value sv1(expected<Value, Status>(unexpected(st1)));</font>
<font size="+1">status_value sv2(</font><font size="+1"><font size="+1">expected<Value, Status>(value)</font>);</font>
</pre>
Next follows equivalent usage<br>
<pre><code>
(</code><code>n4233)
</code><code>Value e = q.value_pop().value();
</code><code><code>(expected based option 1)
</code>
<code>Value e = q.value_pop().value();
</code>
(expected based option 2)
</code></pre>
<pre><code>Value e = q.value_pop().value().value();
==============
</code>
<code>(</code><code>n4233)
</code>
<code><code>auto sv = q.try_pop();
if ( sv.status() == queue_op_status::success )
do_something_with(sv.value());
else
do_something_else_with(sv.<wbr>status());</code>
</code>
<code>(expected based option 1)</code>
<code></code>
<code>auto sv = q.try_pop();
if ( sv )
do_something_with(sv.value());
else
do_something_else_with(sv.<wbr>error());</code>
<code>
</code><code><code>(expected based option 2)</code>
<code></code>
<code>auto sv = q.try_pop();
if ( sv.value() )
do_something_with(sv.value().<wbr>value());
else
do_something_else_with(sv.<wbr>value().error());</code>
<code>
</code>
(expected based option 2)</code>
<code></code>
<code>auto sv = q.try_pop();
if ( sv.value() )
do_something_with(sv.value().<wbr>value());
else
do_something_else_with(sv.<wbr>value().error());</code>
<code>
</code>
<code>==============
</code>
<code><code>(</code><code>n4233)
</code>
</code><code><code>if ( auto sv = q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.<wbr>status());</code>
</code><code><code>(expected based option 1)
</code>
<code>if ( auto sv = q.try_pop() )
do_something_with(*sv);
else
do_something_else_with(sv.<wbr>error());</code></code>
<code>
(expected based option 2)
</code>
<code>if ( auto sv = q.try_pop().value() )
do_something_with(*sv);
else
do_something_else_with(sv.<wbr>error());</code>
Vicente
</pre>
</div>
</blockquote>
</div>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a moz-do-not-send="true"
href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a moz-do-not-send="true"
href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br>
Visit this group at <a moz-do-not-send="true"
href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br>
</blockquote>
<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
--------------000402060306060101020500--
.