-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving Ok
-wrapping for try
blocks
#70941
Comments
Do we have language team consensus on the specific position that @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I still dislike the implicit control flow, but I do have to admit that this is a pretty elegant argument, and I also have to admit that |
@mark-i-m This issue isn't about any other property of |
@joshtriplett Sorry, perhaps it's a poor choice of words on my part, but I mean that we are calling the (But either way, I don't wish to create noise on this thread, so I'm content to just drop it) |
Does that stabilise and sets in stone that try blocks do Ok wrapping if it gets accepted, or is it just to experiment in nightly with try blocks doing Ok wrapping? |
@nox point of information: |
So that sets in stone that if try blocks get stabilised, they will do so with Ok wrapping and that cannot be discussed anymore, is that it? |
@nox Correct. That is what we are deciding on. |
Forgive me for belaboring the point here: Am I right that when everyone in this issue (and in the linked discussion on #31436) says That is, I'm trying to understand if @joshtriplett is proposing that we (simply) commit to the current behavior, where, according to @Centril 's note above, we already have Or if instead, @joshtriplett is proposing that we wrap the result expression of a I would be in favor of the former. I would need to see more arguments explaining why the latter is better. (I can imagine why one might choose this option, namely there may be scenarios where type inference is unable to determine the desired instance of the |
This issue isn't about whether we wrap using In this issue I'm just seeking consensus on whether we should do wrapping at all. |
Thank you for the clarification @joshtriplett @rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Note: despite rfcbot's handling, I'd still like to get responses from @cramertj and @withoutboats as well, to confirm that we have full consensus here. |
So I started a comment some time ago but it seems like I never finished it. I just wanted to note my full thoughts. I'm in favor of ok-wrapping. I do have some mild other concerns about try block -- in particular it is frequently necessary in practice to give hints as to the try of a try-block. This is for a few reasons:
Therefore, I think we should consider some syntax that makes it either mandatory or at minimum convenient to annotate the type -- something like |
I'm not sure how much you'd like to continue this discussion here @nikomatsakis. However, like @scottmcm (as they elaborate on in rust-lang/rfcs#2388 (comment)), I'm also not in favor of a strict requirement that the type be included. As for |
What reasonable code would cause ambiguity that only exists with |
I'd prefer not to continue the discussion here. I just wanted to note that this "rfcbot reviewed" on my part is not saying "let's stabilize try as is", but just on the ok-wrapping aspect. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
ping @withoutboats; we still would like to see full consensus here. Though I suppose it's a pretty fair bet you're in favor of |
Pinging @withoutboats again... I'm sorry if this is not OK, just saw that this has been inactive for some time :) |
Sorry for never replying on this thread. I think it's well known that I am in favor of try blocks ok wrapping. But along the lines of @nikomatsakis's comment, I think someone needs to thoroughly review the state of try blocks other than ok wrapping before we stabilize them (this issue has drowned out any other issues that probably exist with try blocks). |
I'm going to close this as resolved. Thanks all. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I am sure this has been already discussed over many times,
the result is |
Please read this issue all the way through before commenting; this issue carefully pulls out one particular bit of a previously contentious topic for evaluation in isolation.
There's been a long-standing dispute that blocks the stabilization of
try
blocks: whethertry
should wrap its final value inOk
or not, referred to by the shorthand of "Ok
-wrapping".There's been extensive discussion on both approaches. Within the language team, that discussion has remained unresolved for several years, and people have been somewhat hesitant to reopen that discussion. When last we left it, there were a couple of proponents of
Ok
-wrapping, several people who didn't seem to have a strong opinion one way or another, and I was the last remaining holdout arguing thattry
should not doOk
-wrapping.However, two days ago, I read a comment which got me thinking about
Ok
-wrapping again; in particular, the elegant observation that it makestry
and?
symmetric, such thattry { x }? == x
andtry { x? } == x
. I also thought about much of the Rust code I've written recently, including its error handling. This got me to do some introspection, which led to the realization that I don't actually object toOk
-wrapping specifically, and in fact I thinkOk
-wrapping is the right answer.What I realized I actually object to is some of the proposed syntax for function-level
try
, which hides theResult<T, E>
type behind something likeT throws E
. (I am not going to go into any of my objections to such syntax, as it's off-topic for this issue.) I'd so commonly seen that andOk
-wrapping presented together as a unit that it hadn't occurred to me to separate the two and evaluate them independently. Once I did, I realized I didn't actually have any objection toOk
-wrapping.And, as it turns out, we can separate those two, because
try
blocks don't depend on any syntax for function-leveltry
. We can evaluate and stabilizetry
blocks independently, and the only disagreement about that was overOk
-wrapping.So, with that in mind, I'm filing this issue to separate out and gauge language-team consensus on the specific question of
Ok
-wrapping intry
blocks. I'd to focus only on that point within this issue, so that we can determine if the lang team now has a consensus on that topic with my objections now withdrawn.In particular, this issue is not about function-level
try
or any syntax for it, nor about theTry
trait and any issues that may need resolving with that trait before we can stabilizetry
blocks. Finding consensus here does not mean thattry
blocks are completely ready to ship; I'd just like to evaluate this one issue in isolation and confirm that it's no longer an issue.The text was updated successfully, but these errors were encountered: