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
-
-
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 -
Hmm the comparison to unsafe is interesting, but do you think that was a mistake? I think it’s very easy for a new user to just think of the function as an unsafe scope, and similarly here think of the function as a catch boundary
2 replies 0 retweets 0 likes -
I see no reason why we shouldn't have used vouch {} or trust {} and strongly prefer them. The problem with "catches" is that the English word really implies that it was caught inside the boundary. But actually it's saying "you need to catch".
1 reply 0 retweets 1 like -
Replying to @wycats @withoutboats and
Further, if we're comfortable with the word "catch" the verb that creates a thing to be caught is "throw". We should either go with the analogy or find another one :)
2 replies 0 retweets 1 like -
I think the analogy is clear but different. ?/throw throws, catch catches (and packages it into a result)
1 reply 0 retweets 0 likes -
Right. But a catch function doesn't necessarily need to catch internally. In fact I suspect catch blocks will be relatively rare compared to function return catches because you'll use ?. And describing what's going on *inside* the function is not something you want on an API
1 reply 0 retweets 0 likes -
I don’t follow your thought process A catch function and a catch block are both “catch” boundaries. Why should a catch function contain catch blocks????
2 replies 0 retweets 0 likes
"catches takes an exception and turns it into a Result" has something to it, but it's not congruous with the one-frame reality of the Result time. That mental model really implies that if you don't "catch" it keeps going.
-
-
No but that’s the wonderful thing about catch: this is how we’re different, we don’t let you throw nonlocally, you have to explicitly (
) re-throw in each function, no hidden control flow paths1 reply 0 retweets 2 likes - 3 more replies
New conversation -
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.