On Wed, Sep 12, 2018 at 3:25 PM Andrzej Krzemienski via Boost < boost@lists.boost.org> wrote:
czw., 13 wrz 2018 o 00:18 Peter Dimov via Boost
napisaĆ(a): Andrzej Krzemienski wrote:
You have just described something that one could call "value or throw" idiom: `foo().value()`. It will only work under certain policies: [...]
The basic point here is that "value or throw" or "value, period" are used in different ways. One is
auto r = function().value();
and the other is
auto r = function();
if( r ) { // use the value of `r` }
Since the two forms are distinct, it doesn't really make sense to express both using the same name because then you can't tell at a glance whether the code is correct or not.
Yes, they are two distinct cases. And yes, they should probably be expressed in two different ways.
My understading was that initally Outcome attempted, in part, to be an easy solution to this problem (building interfaces which return value-or-throw results). It appears that this functionality is now deeply burried in policies and other complexity (assuming it still exists, which is still unclear to me). I assume this is driven by pressure from users who don't want to use exceptions at all. If someone is building an API that simply needs to return value-or-throw results, would Outcome be the recommended provider of this functionality? Is there even a single example of such a library that uses Outcome?