Boost logo

Boost :

Subject: Re: [boost] Noexcept
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-06-19 09:58:58


2017-06-14 21:52 GMT+02:00 Richard Hodges via Boost <boost_at_[hidden]>:

> Exception return paths are not infinite. There are a finite number of
> places in code that an exception can be thrown.
>
> The exception path is one path, the non-exception path is another. That’s
> two in total. Exactly equivalent to an outcome<>.
>
> It is a fallacy to say that there are an indeterminate number of paths.
>
> If developers do not understand RAII, then an afternoon of training can
> solve that.
>
> RAII is the foundation of correct c++. It is the fundamental guarantee of
> deterministic object state. A program without RAII is not worthy of
> consideration. The author may as well have used C.
>
> Perhaps there is an argument that says that RAII adds overhead to a
> program’s footprint. If things are that tight, fair enough.
>
> Otherwise there is no excuse to avoid exceptions. I’ve never seen a
> convincing argument.
>

The above statement almost treats RAII and exception handling as
synonymous. But I believe this gives the false picture of the situation.

RAII is very useful, also if you do not use exceptions, but have multiple
return paths. You want to acquire the resource in one place and schedule
its future release in one place, not upon every return statement.

In case of using things like Outcome, you still want to follow RAII idioms.

People who choose to use Outcome do understand RAII and will still use it.
But RAII does not handle all aspects of failure-safety, and this is about
these other aspects that people may choose to go with Outcome rather than
exceptions. One example: propagating information about failures across
threads, or "tasks".

>
> The fact that people are taking time to re-implement exception
> functionality in outcome<> et al demonstrate the necessity and correctness
> of exceptions.
>
> I have yet to see an answer to my initial question - an example of code in
> which compiling without exceptions enabled and checking return types
> instead, will add any performance benefit to the non-exceptional case at
> all.
>

Looking for alternatives to exceptions is not driven (this is my
understanding) by performance. But by other factors, like explicitness.

The only performance-related objective is that you want a task where
failures occur and tasks with no failures to be performed in comparable
times (rather than one being orders of magnitude slower).

Regards,
&rzej;


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