On 24 November 2010 17:04, Graydon Hoare <gray...@mozilla.com> wrote: > It would be possible, but I get a little tingle about "doing the wrong > thing" when considering adding expression forms that perfectly mirror > statement forms.
IMO it is easier to follow auto x = foo() ? 10 : 11; rather than auto x = if (foo()) { 10 } else { 11 }; The if-else has too much extra parenthesis. And even if one can omit {} and write: auto x = if (foo()) 10 else 11; it is still has 2 extra parenthesis making it harder to perceive. And note that the ternary does not match the "if" as its else part must always present making it sufficiently different IMO. The case would be different if the "if" would have the if-then-else syntax without parenthesis like in auto x = if for() then 10 else 11; But that would be foreign for programmers in C-based languages. > The ternary operator is Not The Most Popular Idea from C The worst abuses that I have seen came from the use of the comma to initialize the temporaries in the middle of the nested ?. Without the comas it is harder to write ugly ternaries. > Besides which, it implies control flow; it doesn't actually evaluate both > arms. So we'd be desugaring it anyway, the way we desugar && and || in > rustboot. See above wrt. "awkward for all parties". That would be an argument if rust would not have && and ||. But with latter available the control flaw implied by the ternary does not look like an issue IMO. _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev