Alternatives to exceptions for error handling
sighoya
sighoya at gmail.com
Tue Jan 5 17:59:41 UTC 2021
On Monday, 30 November 2020 at 11:02:29 UTC, Ali Çehreli wrote:
>That's all... Exceptions are the simplest error management.
+1.
Please leave exceptions as default and optionally introduce other
ways for specific kind of work.
>For me, their only problem is the performance impact, which I
>haven't even measured. :)
But exactly this is the way exceptions are defined, they should
be exceptions, i.e. they should rarely pop up. With this in mind,
code execution with exceptions is as fast as with no error
handling at all, which isn't the case with Rust's error handling.
What you may want instead are signals which implicitly pass a
pointer of possible continuations down the stack or maybe by just
overwriting a global continuation variable to quickly jump in.
They are interesting for cases where you expect an event to
happen more than not.
Disadvantages are however:
- a small footprint registering landing pads (catch
regions/continuations)
- don't fit that well with reference counted objects
More information about the Digitalmars-d
mailing list