'unwrap envy' and exceptions

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Sep 12 01:50:37 UTC 2021


On Sat, Sep 11, 2021 at 08:13:07PM +0000, Dukc via Digitalmars-d wrote:
> On Friday, 10 September 2021 at 23:20:17 UTC, IGotD- wrote:
> > 
> > Walter mentioned that exceptions are on the way out because they are
> > expensive and inhibits the optimizer which are fair points. I
> > interpreted this that Walter wants to move away from exceptions in
> > D.  Since then I haven't seen any proposal for any new error
> > handling for D.
> 
> Well the `@nodiscard` proposal, that is very likely to get accepted,
> is sort-of one. It's basically about returning traditional error
> values, but forcing the user to be explicit if she really wants to
> summarily discard them.

Whatever replaces exceptions better be darned good, otherwise I will be
very unhappy.  Explicit exception handling has its place, but in other
cases it just uglifies code for no good reason.  I don't really buy the
performance argument: if your profiler pinpoints try/catch blocks as the
bottleneck, it's not hard to refactor it to use error codes instead.
Anything else is premature optimization.  We should not uglify code just
for some idealism that exceptions are somehow "bad".


T

-- 
EMACS = Extremely Massive And Cumbersome System


More information about the Digitalmars-d mailing list