3 ms·
I like C# but I've really come to dislike the idea of exceptions and null after working with Rust. I think C# would benefit from a Result/Option addition.
by hypeatei 4y ago
I like C# but I've really come to dislike the idea of exceptions and null after working with Rust.
I think C# would benefit from a Result/Option addition.
- code_runner 4y agoIt should be a simple wrapper Func<> with a generic Option<T>. I’m sure there is a library out there doing it already.
- svick 4y agoFor null, there are nullable reference types now. Exceptions are here to stay though. I don't see how you could retrofit something like Rust's Result on top of .Net. (Also, .Net has a pattern that's an alternative to exceptions: `bool TrySomething(out T result)`. But it's quite limited, in several ways.)
- ttymck 4y agoAre you suggesting a Result type and Exceptions are mutually exclusive? Scala bolted `Either` (a Result type) on top of Java, and it worked exceptionally well in my experience.