Idiomatic way to express errors without resorting to exceptions

Sebastiaan Koppe mail at skoppe.eu
Sat Feb 29 13:03:21 UTC 2020


On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote:
> * Option!T from the optional package: Has even worse problem 
> IMO. Not only it allows None + int but also it returns a `[]`. 
> This API is not to my liking. You could say well Haskell has 
> fmap for Optional etc, and I am aware of that, so does Rust 
> with map etc. But I am talking about basic things: like `+`.

I would argue it is one of its strengths.

Regardless, I don't think option/nullable/maybe is a good type 
for errors. Rather you should use something like SumType!(T, 
Error), or any other 'either' type.


More information about the Digitalmars-d-learn mailing list