Comment by Quarrelsome

21 hours ago

none of that applies to my position. I have an appreciation for almost all of C# and am comfortable in the framework. I just want to know what situations would be better suited to using them than traditional approaches.

I get there's an .Either pattern when chaining function calls so you don't have to do weird typing to return errors, but I'm using exceptions for that anyway, so the return type isn't an issue.

The Result pattern can be a lot more ergonomic than exceptions.

Microsoft C# guidelines recommend try-parse (which is just the Result pattern, albeit somewhat cludgy with no unions) over exceptions.

https://learn.microsoft.com/en-us/dotnet/standard/design-gui...

  • the result pattern doesn't force you to handle the exception though. You can just discard the result.

    • A function that returns `Result<T,E>` is not a `T` and cannot be implicitly converted to one. If you want to use that `T`, the only way is writing code that drops or handles the `E`. If you don't, your program does not compile.

      Compare this to exceptions, where the type is just `T` and can be used without further ceremony. You can discard the error by forgetting a handler. Now you have a program that occasionally crashes.

      Follow-up: Are there async exceptions? A `Result` is just data that can be awaited. How would that work with exceptions?