There's no ambiguity, the keyword could be anything. But half of people say `throws` is wrong and the other half say `catches` is wrong.
-
-
-
Replying to @ManishEarth @nick_r_cameron
I ended up going with `catch` because a) the function "catches" the error to bundle it into a result, then you "throw" it again with `?`, b) it has very similar semantics to just putting `catch { }` inside your function
3 replies 0 retweets 3 likes -
Replying to @withoutboats @nick_r_cameron
I suspect throws will help folks coming from other languages, and it fits more naturally into the function as a sentence. The problem with "it's catch because it catches it" is that it leads to a mental model that makes you want to put catch on all fns catching even sans rethrow
1 reply 0 retweets 1 like -
Besides, APIs shouldn't describe what's going on internally.
1 reply 0 retweets 1 like -
Using `catch` for opposite-ish things reminds me of `static` in C and the confusing nature of addr-of and by-ref syntax both using & even when they mean opposite things.
2 replies 0 retweets 0 likes -
It has a similar problem imo as the two uses of `unsafe`. I think we can do better than `catches`. Do we not like `throws` because it gives the wrong idea to Java programmers?
2 replies 0 retweets 1 like -
Exactly yeah. I think it gives the right idea, really. Though I guess making folks think we're like <other language that is different> might lead them to assume more than they should.
1 reply 0 retweets 0 likes -
I think it would be fine to tell new developers "it's like an exception but it only bubbles with `?`" A little later: "Also if you don't use `?` you can get your hands on the Result"
2 replies 0 retweets 1 like -
Yeah. Correctly constructing the mental model is key. However. We can't just assume that folks will read The Book. They may read a different book, or learn this feature by reading code (that's what I'd do). So designing the thing such that it's not easily misleading is important
1 reply 0 retweets 0 likes
Totally agree. We should strive to: First, make it self explanatory. Second, use error messages to guide. And as a last resort, make sure the documentation will help those who manage to find it. In that priority order.
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.