Subject: Re: Are Exceptions deeply flawed?
From: Thiago Macieira (thiago_at_[hidden])
Date: 2019-08-06 00:16:29
On Monday, 5 August 2019 01:45:13 PDT Dmitry via Std-Discussion wrote:
> I wrote a post -
> y_deprecated/ in the hope to get answers to at least 3 questions at the top
> because the are very practical and I have to deal with them every day.
> I would be grateful to here what you think.
Disclaimer: I don't use exceptions in my code, my libraries never throw, I
never test exception-safety.
But I think you've fallen into the fallacy of focusing on the mechanism
instead of the objective. The exception is the means to transport an error
condition in a type-safe manner and unwind the stack. The same can be
accomplished with error conditions and returns and in fact does happen: I can
make your situations more concrete based on what I did at work today: I had a
function f() that opened a temporary file and returned a file descriptor, but
instead of opening a real file, now it opens a Linux memfd. That means EACCESS
can no longer happen. At the same time, we can get an ENOSYS if you're running
on Linux less than 3.17.
How does the caller's code get updated to handle the new condition and stop
handling the now never-impossible one?
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel System Software Products
STD-DISCUSSION list run by herb.sutter at gmail.com
Older Archives on Google Groups