Re:Announcing Rust 1.13
by QuantumLogic on Thursday November 10, 2016 @04:41PM
(#12924674)
I don't get why they'll let the language be abstracted in that way, but are against having ternary operators. It's the one thing that's somewhat bugged me about Rust. Aside from this one minor thing, I"ve been really loving the language itself.
Is a lot better than having to write this all the time:
[ Parent
| on HN ]
But…. these are two completely different statements, the equivalent Rust is
if a < b { b } else { a }
why are you adding sprurious returns? And if you need to get the minimum of two values so much that actually impacts you, write a `min!` macro?
Re:Announcing Rust 1.13
by shepmaster on Thursday November 10, 2016 @05:43PM
(#12925249)
No macros needed!
use std::cmp::min;
min(a, b);
https://doc.rust-lang.org/std/cmp/fn.min.htmlHa. I should have known, thanks.
Re:Announcing Rust 1.13
by steveklabnik on Thursday November 10, 2016 @04:43PM
(#12924691)
This doesn't duplicate anything in the language; it moves a stdlib macro to be included in the core language.
Since if is an expression, ternay operators would be wholly redundant.
Re:Announcing Rust 1.13
by QuantumLogic on Thursday November 10, 2016 @04:46PM
(#12924713)
The whole point of it would be to have a higher level of abstraction which makes codebases more concise. Avoiding duplication for the sake of avoiding it is as nonsensical as avoiding 100 dollar bills since we already have 100 single dollar bills that could make it up.
> The whole point of it would be to have a higher level of abstraction
What are you talking about? A ternary isn't a higher level of abstraction, it's at best the exact same thing with a different syntax, at worst it's a more limited version of the same.
I tip my hat to you for remaining committed to one of the oldest Rust trolls there is.