Alternatives to exceptions for error handling
Paulo Pinto
pjmlp at progtools.org
Sun Nov 22 18:17:58 UTC 2020
On Sunday, 22 November 2020 at 17:37:18 UTC, Roman Kashitsyn
wrote:
> In the video from DConf 2020 about @live functions
> (https://youtu.be/XQHAIglE9CU) Walter mentioned that all @live
> functions are nothrow. He also thinks that exceptions are
> obsolete.
>
> I've been programming in Google's C++, Go & Rust for quite a
> few years and I couldn't agree more with this assessment.
> Error handling is a very important part of program engineering,
> and having errors reflected in function return types is very
> useful in practice. This helps a lot with constructing correct
> programs.
>
> So my question is: does/will D provide support for alternative
> approaches to error handling? In practice, this typically
> includes 2 things:
>
> 1. A sum type that contains either a result or an error. Like
> Result in Rust or Expected that Andrei proposed for C++. It's
> easy to implement in D, but having this in Phobos would be nice.
>
> 2. Some kind of syntactic sugar for propagating errors upstream
> (? macro in Rust, check/handle proposal in Go
> https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling.md, an ugly macro in C++, etc.).
You won't need ugly macros in C++,
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0709r0.pdf
More information about the Digitalmars-d
mailing list