Skip to content
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

Consider having a ? operator on calls (like Rust) for error propagation #558

Open
masak opened this issue Feb 9, 2021 · 3 comments
Open

Comments

@masak
Copy link
Owner

masak commented Feb 9, 2021

Last time I looked at Rust, they had a try! macro for this, but now they have a ? postfix operator; if "postfix" isn't stretching the terminology a bit here. (Note to self: check if it's actually implemented as a postfix ? in the parser, or whether it's the call syntax rule that has been extended. Either would work, but from slightly different directions in the grammar.)

Similar to #13, this operator affects the rest of the execution, but unlike that issue, it does it by returning early.

We don't have a Result type like Rust does; it's an open question how much such a type would require a static type checking mechanism.

@vendethiel
Copy link
Collaborator

I feel like this brings us back to the discussion on whether or not you should be able to use a return from a quasi; and that it should return from the function the quasi is injected into.

@masak
Copy link
Owner Author

masak commented Feb 9, 2021

Dammit! At first blush, you're right! It's here and now that my stubbornness on that issue is coming back to bite me...

I feel that, if I start turning over one stone here, I'll end up turning over them all (again) — which may or may not be worthwhile. So for the moment, let me just agree with you @vendethiel, with absolutely no further strings attached.

@masak
Copy link
Owner Author

masak commented Feb 11, 2021

I feel that, if I start turning over one stone here, I'll end up turning over them all (again) — which may or may not be worthwhile.

No, it seems I was already convinced in the past, as evidenced by #483. We just haven't Made It So yet. So all's fine, and return will return from whatever's in the mainline, not in the macro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants