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: whether try should wrap its final value in Ok 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 that try should not do Ok-wrapping.
However, two days ago, I read a comment which got me thinking about Ok-wrapping again; in particular, the elegant observation that it makes try and ? symmetric, such that try { x }? == x and try { 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 to Ok-wrapping specifically, and in fact I think Ok-wrapping is the right answer.
What I realized I actually object to is some of the proposed syntax for function-level try, which hides the Result<T, E> type behind something like T 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 and Ok-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 to Ok-wrapping.
And, as it turns out, we can separate those two, because try blocks don't depend on any syntax for function-level try. We can evaluate and stabilize try blocks independently, and the only disagreement about that was over Ok-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 in try 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 the Try trait and any issues that may need resolving with that trait before we can stabilize try blocks. Finding consensus here does not mean that try 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.
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
tryblocks: whethertryshould wrap its final value inOkor 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 thattryshould 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 makestryand?symmetric, such thattry { x }? == xandtry { 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
tryblocks don't depend on any syntax for function-leveltry. We can evaluate and stabilizetryblocks 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 intryblocks. 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
tryor any syntax for it, nor about theTrytrait and any issues that may need resolving with that trait before we can stabilizetryblocks. Finding consensus here does not mean thattryblocks 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.