4 ms·
I know this seems like a trivial issue, but I've been bothered by the try!() macro for a while. I keep hoping then will adopt the "?" postfix operator to mean t
by jeffdavis 11y ago
I know this seems like a trivial issue, but I've been bothered by the try!() macro for a while. I keep hoping then will adopt the "?" postfix operator to mean the same thing, because it seems to increase readability a lot.
I'm open to other ideas too, but that seemed like the simplest way to get the error handling out of the way.
Ordinarily I try hard not to complain about syntax, but this seems to cause people to use .unwrap() where it's not safe (like a library).
- steveklabnik 11y agoThere was major movement on the ? syntax last night, actually.
- jeffdavis 11y agoGreat to hear! Thank you.
- steveklabnik 11y agoNo problem. To be more specific, https://github.com/rust-lang/rfcs/pull/243#issuecomment-163308249 https://github.com/rust-lang/rfcs/pull/243#issuecomment-1633... and https://github.com/rust-lang/rfcs/pull/243#issuecomment-163388772 https://github.com/rust-lang/rfcs/pull/243#issuecomment-1633... TL;DR: we're still adjusting process a bit, but the idea is that this is "good enough" to actually land, behind a feature gate, to start gaining experience. We still reserve the right to tweak it before it goes stable, but it's better to get it into people's hands, rather than continue to debate the last few minor points.
- Argorak 11y agoHuh, does that reflect in RFCS or something somewhere? I'm quite pleased by the current solution and am not such a big fan of "?".
- jeffdavis 11y agoI'm curious what you do. Do you use try!() extensively, and fine it just fine? Or do you use something else, like .unwrap()?
- Argorak 11y agoYep, I just use try!(), with the appropriate From implementations.
- dbaupp 11y agoYes, on the RFC: https://github.com/rust-lang/rfcs/pull/243#issuecomment-163308249 https://github.com/rust-lang/rfcs/pull/243#issuecomment-1633...
- lmm 11y agoIt seems really wasteful to be working on a specific macro rather than a general-purpose solution (i.e. an equivalent of do notation or scala's for/yield) that will work for things other than error handling.
- steveklabnik 11y agoIf you want duck-typed do, there's https://crates.io/crates/mdo https://crates.io/crates/mdo If you want real do, and I do, then you need HKT, which is a massive upgrade to our type system that will take a very long time. If we can do something simpler in the meantime to ease some pain, then it's worth it.
- eximius 11y agoThere was just a burst of conversation on this and I think it will be accepted under a feature gate while they work some Type stuff out
- aldanor 11y agoAgreed, if you work with I/O, all the try!(try!(try!())) start making your eyes bleed. The ? suggestion is quite brilliant, been waiting for progress on that for a long time