|
|
|
|
|
by pcvarmint
2941 days ago
|
|
(I use "conditional expression" in place of "ternary operator" here.) I have no idea why GoLang doesn't have conditional expressions. I find a conditional expression to be much easier to parse than if-else statements. If it's too hard to read, then why is LISP written almost totally as expressions, and is still considered viable? a ? b ? c : d : e
is much easier for me to read and understand than if (a) {
if (b) {
r = c;
} else {
r = d;
}
} else {
r = e;
}
GoLang is supposed to be designed to remove "boilerplate code" and reduce code size, so I don't know why it doesn't have conditional expressions.Without conditional expressions, C++11 (but not C++14 and later) constexpr functions wouldn't be Turing-complete. |
|
You're often better off if you put it behind a macro:
In C coding, a lot of ternary action happens behind the curtain of preprocessing, where expression is almost fully parenthesized.