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 -
Replying to @wycats @ManishEarth and
That explanation kinda sounds too magical to me, vs. teaching the types - there's nothing special about the type besides the ? (and soon throws/catches/w.e) sugar and it being standard, and leading users to understand the types seems better?
2 replies 0 retweets 1 like
I think you teach the types real quick. The point where you teach that you can get your hands on the Result is when you teach it's a Result. I think it would come pretty early too.
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.