Re:Fast Rust Builds
by GolDDranks on Sunday September 05, 2021 @11:06PM
(#28429838)
Didn't downvote you because I presume you are arguing in good faith, but I have very different opinion about the ? operator, it is one of the best syntactic things in Rust. In my experience, many Rustaceans agree. It's a minimal nuisance, while still being explicit in a good way.
Also, being able to call unsafe code inside unsafe functions is now considered a design mistake, and there is ongoing work to revert the default – requiring unsafe blocks even in unsafe functions: https://rust-lang.github.io/rfcs/2585-unsafe-block-in-unsafe...
But `foo()?"A context message for a human".bar();` is even better. Currently, we must use anyhow's `foo().context("Message")?.bar()` [1] for that.
[1]: https://docs.rs/anyhow/1.0.42/anyhow/trait.Context.html
Re:Fast Rust Builds
by p4lindromica on Sunday September 05, 2021 @11:09PM
(#28429854)
The compiler does have a lint to force being explicit about unsafe in the way you describe. It is an allow by default lint called `unsafe_op_in_unsafe_fn`.
A proper language needs to allow the programmer to choose between implicit effects and explicit effects on a case-by-case basis. The reason ? is so tragic is because Rust tried to go with explicit effects only, but found that people wanted implicit effects, and ? is the closest that Rust can get. That's why it's syntactic noise: The programmer wants to get rid of it, they don't regard it as informative for this case, but they can't get rid of it.
(And checked exceptions can be perfectly well implemented with regular data, you don't need any special cases - in fact, you can do it with the same infrastructure that's already been added in a special-cased form for async/await support...)