Boost logo

Boost :

Subject: Re: [boost] [review] Review of Outcome v2 (Fri-19-Jan to Sun-28-Jan, 2018)
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2018-01-28 04:10:57


On Sat, Jan 27, 2018 at 4:13 PM, Niall Douglas via Boost <
boost_at_[hidden]> wrote:

> > I was only talking about semantics. Are you saying that, except for
> > performance considerations, there is no reason to use
> >
> > OUTCOME_TRY(handle, open_file(path));
> > OUTCOME_TRY(buffer, read_data(handle));
> > OUTCOME_TRY(val, parse(buffer));
> > return val;
> >
> > instead of
> >
> > return parse(read_data(open_file(path)));
>
> It is rare that functions would consume an Outcome as a parameter. After
> all Outcome is not Expected, and Default Actions get a throw site away
> from the cause of the error.
>

My question is really what is the use case for OUTCOME_TRY. I'm asking
because the above use of OUTCOME_TRY is literally the first example given
in the Outcome documentation, yet the code would be simpler, more readable,
more robust and, it seems to me, semantically very similar if it used
exceptions instead. So the question is what's the upside of using the
cumbersome macro rather than relying on exception handling? Is it just the
perceived performance improvement?

Emil


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk