Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upEscape Blocks and Labels as try/catch/throw control flow building blocks #2440
Conversation
phaylon
added some commits
May 13, 2018
This comment has been minimized.
This comment has been minimized.
|
As you probably gathered from my comments on the related RFCs, I share the skepticism that the various error handling sugars being discussed are a net win, and am extremely sympathetic to the motivation behind this RFC. My only serious concern is that it's not clear to me that the holistic experimentation this RFC allows for would cover the whole design space, and thus we might end up biasing against certain designs that I currently have no idea how to evaluate. Specifically, I don't see how I'd be able to implement any of the following as macros:
It looks like you can do (though, even if I'm right and this RFC does turn out to exclude a lot of potential designs, it might still be a better approach than continuing to design these sugars by a series of discussions with no practical experimentation of a complete sugar system) |
This comment has been minimized.
This comment has been minimized.
|
@Ixrec Yes, it is more aimed at the current functionality proposals. I'm unsure how some of your examples would look like in code:
Do you mean actual
In the given scenario, something like that would work via an explicit result-setting macro. Otherwise I'm unsure how this can work. Especially when mixing
Not sure I understand this at all :) Could you clarify "return expressions" and "change" for this context?
Unsure what
As I understand it, yes, this would simply an Ok-wrapped block.
There is the break-with-value feature, which allows Those could be combined in a macro though, I assume. Example:
would translate to something like
Of course the semantics change depending on where you insert things like |
This comment has been minimized.
This comment has been minimized.
rpjohnst
commented
May 13, 2018
|
I'm not sure how this solves the problem it claims to. It still stabilizes a particular mechanism that, this time, doesn't fit into any overall error handling system, and would thus continue exist alongside whatever final solution we would presumably get later. That was fine for something like |
This comment has been minimized.
This comment has been minimized.
It could be a final feature. The RFC contains an example with an It also doesn't have any API implications, so if we end up with enough other functionality in core that this is no longer needed, it can be deprecated for better alternatives. I'd personally keep using this with errors even if auto-wrapping |
This comment has been minimized.
This comment has been minimized.
|
I agree with @rpjohnst here; this seems to be " Also, this would still need to reserve |
scottmcm
added
the
T-lang
label
May 14, 2018
This comment has been minimized.
This comment has been minimized.
It's not only for that. Like I said above, I'd personally choose it over
I'm open to different names. I also proposed |
This comment has been minimized.
This comment has been minimized.
As @scottmcm said, there is no technical difference between Beyond allowing for more experimentation in the ecosystem as to the final semantics of For more discussion, see: https://internals.rust-lang.org/t/an-alternative-proposal-to-try-catch-throw-error-handling/7474 |
This comment has been minimized.
This comment has been minimized.
An additional label and no wrapping by design does seem like a technical difference?
From the RFC:
Similar for constructs that want to potentially have So, given
It makes sense to me because:
|
This comment has been minimized.
This comment has been minimized.
We can always add
Rewritten in terms of let item = try {
for item in items {
let data = verify(item)?;
if matches(data) { fail data; }
}
fail MyError::NotFound;
};
This seems like precisely the kind of barely-orthogonal feature set that was argued against in "Raising the bar for introducing new syntax".
You are certain of this, because?
You say it is a lot; but I think almost all uses will boil down to be |
This comment has been minimized.
This comment has been minimized.
Only if
I would argue that discussion was about things like
What type are you wrapping with? If there's no implication of the specific situation where you'd use it, what variant of the output type will it be wrapped with? This would mean if it were to convert, it would be some general form of conversion, in other words an
I'd argue then we wouldn't be reserving You've been arguing this from a point of |
This comment has been minimized.
This comment has been minimized.
|
@phaylon The distinction between "currently" and what is possible wrt.
Actually, the discussion started with
The macro could / would do a specific conversion for a specific set of types.
No; I'm for "the current plan" -- but having |
This comment has been minimized.
This comment has been minimized.
To me, though, that loses the promise I thought this RFC was going to have. It takes it from general low-level control flow construct, like label-break-value, that would be there for macros to experiment and could become part of the dialectical ratchet, and instead makes it an opinionated semantic control flow construct, because accepting it would hit all the same "should it do Ok-wrapping" discussions that exist with So I don't see the pro-
But |
This comment has been minimized.
This comment has been minimized.
I disagree here, because
I disagree. This basically seems to me like you're saying " I can see why you'd see this as a
That Edit: Removed the argument about needing a more complicated macro, you're correct that |
This comment has been minimized.
This comment has been minimized.
My point was in reference to there being a supposed important difference wrt. there being an automatic label or not. In this respect there is no technical difference; only a difference wrt. what we want / don't want.
Why not the other way around? It is fully possible to add a more general mechanism if we need to that works integrates well with More or less all the macros you've referenced in the RFC are ones that could be build on top of an Ok-wrapping |
This comment has been minimized.
This comment has been minimized.
My disagreement here is that core would have the more specialized version, while you'd need a dependency for a single macro that is more general.
I believe that to be subjective. I often have blocks resulting in Maybe our fundamental disagreement is because we write code differently. |
This comment has been minimized.
This comment has been minimized.
|
Self-closing since there doesn't seem to be much support for this. |
phaylon commentedMay 13, 2018
Given the recent disagreements about the future of Rust error handling syntax and semantics, this RFC aims to, among other things:
Rendered