Pre-RFC: catching functions https://internals.rust-lang.org/t/pre-rfc-catching-functions/6505 … cc @nick_r_cameron
-
-
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
-
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".
-
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 :)
-
I think the analogy is clear but different. ?/throw throws, catch catches (and packages it into a result)
-
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
-
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????
-
Oh, I see your reasoning. No, my point is that with a catch block we care what's inside. With a catch function we do not, you look at functions from the outside as a black box.
-
Why do we care or not care what’s inside in each case?
- 11 more replies
New conversation -
-
-
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.
-
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"
-
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?
-
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.
End of conversation
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.