3 ms·
> I can depend on the compiler telling me if I haven't done so exhaustively, via the Result type That's going to get tiresome after about half a day. Exceptio
by kazinator 4y ago
> I can depend on the compiler telling me if I haven't done so exhaustively, via the Result type
That's going to get tiresome after about half a day.
Exceptions or GTFO.
- nine_k 4y agoIf you think Result is not ergonomic enough, try writing some Go. In fact, you can often return Result from an underlying function from your own, achieving an effect similar to exceptions.
- 3a2d29 4y agoI will die on the hill that Exceptions are absolutely terrible for readability and control flow and should die. Result<> or Go returning many values is wayyyy better.
- kazinator 4y agoI will bury you and then unwind your stack, and clean up everything.
- kazinator 4y agoI'm so convinced that there exceptions are the superior article, that basically there is no hill worth dying on that can even be identified. It would be like saying that I'm going to personally defend a civilized continent against some fringe bushmen armed with flint arrowheads. I've got an army for that, funded by my taxes.
- satvikpendem 4y agoSorry, I will disagree. It seems like you haven't written any Rust, try it and see how well a Result type works instead of excepting everywhere.
- ColonelPhantom 4y agoThe only difference between exceptions and Result are that you need to change your return type to Result, and that you need to add a ? after calls that might fail. There's also a bit of annoying typing stuff involved, but generally with something like the anyhow crate you can handwave that away too.
- kazinator 4y ago> The only difference That's a significant difference. It's the only difference if you're only considering blub exceptions, and not a nice exception system in which raising an exception doesn't immediately unwind, so that you can have remote handlers choosing local restart points and such. > you need to change Say I can't change it. I want to pass the exception through a third party library I don't control. I don't want to fork it, or can't. Sum types with pattern matching are definitely nicer than some integer error codes or what have you, but for error handling, they are just a lipstick on error codes. People outside of the Rust bubble do know what these concepts are, and about languages like OCaml. Moreover, everyone who ever had anything to do with the concept of the development of exceptions was not an idiot who just didn't see the light of returning a sum type. > you can handwave that away too With what plugin for what editor ... :)