I agree with much of the logic against including the ternary operator, but only if if-else
isn't forcing that noisy brace-delimited syntax:
if !prev { cur } else { prev + cur }
I'd prefer:
if !prev: cur else prev + cur
Or even more clear:
if !prev then cur else prev + cur
Than:
!prev ? cur : prev + cur
But remove syntax coloring and assume we are using a plain text editor:
if !prev { cur } else { prev + cur }
<--- this style isn't available in a Haskell/Python block indenting instead of brace-delimited
if !prev: cur else prev + cur
if !prev then cur else prev + cur
Then the English text variants render low contrast confusing the keywords and the adjacent juxtaposed fragments of code, thus we either need the brace-delimited or the operator delimited ternary:
!prev ? cur : prev + cur
Edit: I added a comment at the issue tracker linking to this post.
Edit#2: I'm thinking the best would be to force only ternary on single or double line if
and if-else
:
!prev ? cur
!prev ? cur : prev + cur
!prev ? cur
: prev + cur
But I'm not sure if I prefer that compared to:
if !prev: cur
if !prev: cur else prev + cur
if !prev: cur
else prev + cur
Or:
if (!prev) cur
if (!prev) cur else prev + cur
if (!prev) cur
else prev + cur
Or:
if !prev then cur
if !prev then cur else prev + cur
if !prev then cur
else prev + cur
Then for multi-line blocks either brace-delimited or my preferred indented delimited with keywords:
if !prev {
cur
}
else {
prev + cur
}
if !prev
cur
else
prev + cur