https://issues.dlang.org/show_bug.cgi?id=12654
Issue ID: 12654 Summary: std.typecons.ErrorMsg Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: Phobos Assignee: nob...@puremagic.com Reporter: bearophile_h...@eml.cc I suggest to add to std.typecons a cons named "ErrorMsg" (or a similar name) that is meant as a standard way to return an error condition when you don't want to use exceptions (useful in nothrow code). The advantage over Nullable is that it's not just "null" or a value. ErrorMsg is a value or a error message, so it informs what the cause of the failure is. To avoid generating many unused error message strings, I suggest the error message to be not just a string, but a 0-arguments callable that returns a string lazily. The advantage over using a user defined struct or Algebraic is that this is standard, so it gives a standard API, and the lazyness of the error message allows to save computation time to generate the error string. (A similar algebraic is used in other functional languages.) --