|
|
|
|
|
by jonahx
2745 days ago
|
|
Contemptuous scorn seems to be the officially-sanctioned strategy for responding to reasoned critique or even questions about "the go way" within the community. My favorite example here is this arrogant dismissal of the idea that a one line expression, rather than a 5 line mutating statement, might be preferred for conditionally setting a value: if expr {
n = trueVal
} else {
n = falseVal
}
> The if-else form, although longer, is unquestionably clearer. A language needs only one conditional control flow construct. [0]... n = expr ? trueVal : falseVal
"Unquestionably"[0] https://golang.org/doc/faq#Does_Go_have_a_ternary_form |
|
&&, ||, switch, select, for, and while all do conditional execution in Go.
So the rule is not "A language needs only one conditional control flow construct." The rule is really, "We didn't think a conditional operator was worth it." That's a fine rule, but it's better to be honest about it than to pretend the language was designed around some pure principle that doesn't actually exist.