The person looking at a function does not care what it does inside, they only care that it returns a result. "catches" is the exact opposite of what the function does from this perspective. When writing a catch block you actually do care that it catches the result inside it.
-
-
This is equivocation between the person writing the catch block and the person reading the catch function’s signature, inverted roles 1/2
1 reply 0 retweets 0 likes -
Replying to @withoutboats @ManishEarth and
I *do* care that this function catches an error anyway: I need to handle it or throw it before I can get to that sweet -> T type I actually want
2 replies 0 retweets 0 likes -
Replying to @withoutboats @ManishEarth and
In contrast, when a function throws I get my -> T with no work, I have the option to catch the error or just let it keep throwing
1 reply 0 retweets 0 likes -
Replying to @withoutboats @ManishEarth and
Using catch instead of throw emphasizes the core distinction between this proposal and exception based systems
2 replies 0 retweets 0 likes -
That's a point against throws, not a point for catches. How about "T errors E"? A more neutral term imo.
1 reply 0 retweets 1 like -
Replying to @ManishEarth @withoutboats and
how is this more ergonomic? We’re like 2 characters away from writing Result? (The comma, and a GT/LT) otherwise character count is identical. One just muddies the water that your getting a sumtype return value making is implicit.
1 reply 0 retweets 1 like -
Replying to @valarauca1 @ManishEarth and
Sorry to clap at you but
ergonomics
is
not
about
character
count3 replies 0 retweets 1 like -
Replying to @withoutboats @valarauca1 and
it's kind of funny -- on the one hand "an error is just another kind of return" -- on another hand, "the happy path" is an important thing to be able to read from top to bottom without extraneous noise.
1 reply 0 retweets 0 likes -
Replying to @wycats @withoutboats and
Some people argue that "error handling" deserves the same amount of visual primacy as the happy path code. I think a lot of that argument comes from pain caused by the implicitness of "any function call might throw an exception".
2 replies 1 retweet 2 likes
Once you make the re-throwing explicit, it's time to revisit the value of keeping the happy path clear and visible. Which is what all of these tradeoffs are about imo.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.