3 ms·
"At the limit limit," you can detect the unstructured branches littered through the codebase of people using Result and convert it all into clean structured exc
by saurik 2y ago
"At the limit limit," you can detect the unstructured branches littered through the codebase of people using Result and convert it all into clean structured exceptions, and even automatically remove all the boilerplate this paradigm uses to propagate errors; this is at least a reasonable thought process due to the same reason you can (much more trivially) implement your exception mechanism by burning a return register for an error code and compiling in a ton of branches (which isn't insane if you in fact want to throw an error often: this is all just a tradeoff that Rust made awkward and its community turned into a religious war).
It isn't easy, though, as the Rust way of doing this--letting people pass around a bare Result without the structure of a monad (which is why Haskell's version of this idea looks like exceptions, and why it is so frustrating when people incorrectly claim Rust has "monadic" error handling)--makes it extremely easy to pull off what should be "stunts", such as holding onto a Result and trying to resolve them in an irreducible order; but, "hopefully", most code isn't making that mistake (and you can still implement it by adding a spurious expensive catch in just the places they did that)... but like, that's why I think the person you are responding to might have said "at the limit limit", to really emphasize that this is a pretty complicated reduction to automatically apply globally and truly result in 0 cost.