nothrow by default
Guillaume Piolat
first.last at gmail.com
Fri Jan 10 13:23:47 UTC 2020
On Friday, 10 January 2020 at 03:42:53 UTC, Gregor Mückl wrote:
> The longer this discussion drags on, the more I doubt my
> understanding of this topic.
>
> What exactly is the execution overhead for non-throwing code
> paths?
My understanding is that there is no overhead for functions that
transitively don't throw or catch.
It's also my experience that
A. _the bottlnecksin a program are almost NEVER functions
that throw_ so why optimize the other parts?
B. Giving up a little bit of safety for performance ruins all
potential gains because of the overhead of introducing more bugs.
Fixing one such bug will negate whatever performance gain.
C. If you do need performance AND errors (typically: parsing
without ranges/exceptions vs parsing with error codes) then you
can resort locally to error codes.
D. Error codes makes very easy to forget them, misuse them,
and makes code less readable. They make very easy to conflate
unrecoverable errors and recoverable errors.
The current internet backlash against exceptions is really
puzzling to me: it's a sort of _revisionism_ because in the
trenches exceptions are holding things together so they don't
break more horribly. It think these people don't know how worse
it could be.
More information about the Digitalmars-d
mailing list