People seem to try to write their code as compact as possible, not realizing that they usually only write a piece of code once, but they and others will have to decipher and make sense of it a dozen times in the near future.
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
if (a) { if (b) { r = c; } else { r = d; } } else { r = e; }
Without conditional expressions, C++11 (but not C++14 and later) constexpr functions wouldn't be Turing-complete.
x = a ? b : c;
int x = a ? : b : c;
You're often better off if you put it behind a macro:
#define IF(X, Y, Z) ((X) ? (Y) : (Z))
CPP macros is red herring.
People seem to try to write their code as compact as possible, not realizing that they usually only write a piece of code once, but they and others will have to decipher and make sense of it a dozen times in the near future.