13 Feb
2016
13 Feb
'16
5:53 a.m.
On 2/12/2016 11:36 PM, Emil Dotchevski wrote:
Let's say in your example, the function throws 50% of the times you call it. Assuming this isn't an anomaly, it means that you're not really throwing to indicate a failure, but to report a result. Obviously that's not a good design.
And this is exactly the sort of situation I would want to use result<T> in instead of throwing an exception. I want discriminated union type that is optimized in interface and implementation specifically for transporting a T or an error code. And, if in the design a choice must be made, favors T slightly.