You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since If blocks are expressions, Julia's ternary operator is redundant since it is just a less readable alias for an if block. Furthermore, since Julia uses both : as a separate operator it leads to ambiguous parses in cases like whichrange()?1:2:3:4 (which returns 1 or 2:3:2 in Julia 0.6).
Deprecating the ?: syntax in favor of just pointing people to if blocks would make the language more consistent, it would eliminate the possibility of an ambiguous parse, and it would mean that people coming from Python or Matlab would have one less new bit of syntax to learn. Using if as a ternary expression is natural enough that I don't think that having the same syntax as C is of any benefit tbh.
Regarding the same tradeoff in other languages, Rust had both if expressions and ?: in beta, but deprecated ?: before 1.0. When someone put up a post-1.0 pull request in favor of adding (?:) it was overwhelmingly voted against
( rust-lang/rust#1698 rust-lang/rust#1705 rust-lang/rfcs#1362 ).
The text was updated successfully, but these errors were encountered:
Since If blocks are expressions, Julia's ternary operator is redundant since it is just a less readable alias for an if block. Furthermore, since Julia uses both : as a separate operator it leads to ambiguous parses in cases like
whichrange()?1:2:3:4
(which returns 1 or 2:3:2 in Julia 0.6).Deprecating the ?: syntax in favor of just pointing people to if blocks would make the language more consistent, it would eliminate the possibility of an ambiguous parse, and it would mean that people coming from Python or Matlab would have one less new bit of syntax to learn. Using if as a ternary expression is natural enough that I don't think that having the same syntax as C is of any benefit tbh.
Regarding the same tradeoff in other languages, Rust had both if expressions and ?: in beta, but deprecated ?: before 1.0. When someone put up a post-1.0 pull request in favor of adding (?:) it was overwhelmingly voted against
( rust-lang/rust#1698
rust-lang/rust#1705
rust-lang/rfcs#1362 ).
The text was updated successfully, but these errors were encountered: