4 ms·
All that means is that the `Failure` bubbles up to the very top of `main` (in this scenario) because we're only caring about the happy path (because we can't co
by svieira 11mo ago
All that means is that the `Failure` bubbles up to the very top of `main` (in this scenario) because we're only caring about the happy path (because we can't conceive of what the unhappy path should be other than "crash") and then hits the `panic("Well, that's unexpected")` explicitly in Place B rather than Place A (the `.unwrap`). I'm not sure how that's _better_.
- jacquesm 11mo agoIt would not because it would be a compile time error rather than run time error which is a completely different beast if I understand the argument correctly.
- Dylan16807 11mo agoWhat would be a compile time error? The compiler rejecting unwrap? And then you fix that by bubbling the error case up, which fixes the compiler error and leaves you with a runtime error again. But one that's less ergonomic. You can't force a config file loaded at run time to be correct at compile time. You can only decide what you're going to do about the failure.
- jacquesm 11mo agoThe point they are - trying, apparently - making is that if you had a flag or an annotation that you could make to a function that you do not want that function to be built on top of anything that can 'unwrap' that you can rule out some of these cases of unexpected side effects.
- echelon 11mo agoNot really. Handler and middleware can handle this without much ceremony. The user gets to, and is informed of and encouraged to, choose. We also don't get surprised at runtime. It's in the AST and we know at compile time. The right API signature helps the engineer think about things and puts them in the correct headspace for systems thinking. If something is panicking under the hood, the thought probably doesn't even occur to them.
- svieira 11mo agoYes, but my point is that without a reasonable supervision tree and crash boundary the difference between a composition of Result-returning functions that bottoms out in main's implicit panic and an explicit panic is nil operationally. While lexically the unwrap actually puts the unhandledness of the error case as close to the source of the issue's source as possible. In order to get that lexical goodness you'd need something much more fine grained than Result.