This question:
awk operator precedence of `!a[$0]++`
A perfectly valid question, well written and specific to the issue to solve.
Got classified as a duplicate of:
How does awk '!a[$0]++' work?
Which, on a first look seems like an (also) reasonable question of a quite similar concern.
But, looking a bit deeper, it happens that both answers in that second question have troubling (and incorrect) issues and very conflicting comments about the order of evaluation of the ++:
- The first answer (Archemar) claims that the negation
! is applied first and then the ++. - Gilles claims that that error is actually correct:
the incrementation is indeed applied after the value of the expression is calculated
- G-Man reinforces that interpretation under the cuonglm answer (the second answer).
the ! operator is applied to the value of a[$0] before it is incremented
- And Gilles re-iterate the same in plain words:
This answer is wrong. The incrementation happens after the result of the ! operator is calculated.
At least, without taking any side, both answers result in confusion and noise.
Nobody has taken the time to clean the problem and to make the answers clear.
But yet, we are directing new questions to such conflicting answers.
Full disclosure: I do have a position. I believe that both G-man and Gilles are wrong. The only possible (valid) description is that the operator ++ is (as it must) be applied first to a lvalue and, ... later ... the ! operator is applied.
But the real issue to discuss here is: should we naively direct people to older answers that look (on first sight) the same but are fundamentally conflicting and confusing ?
Note: this question has been written looking at what those answers look like NOW, they will probably be edited and changed. I, for one, will add another answer to try and clear the (several) errors. Of course, after some time has pass to discuss this question.
Question
I hold that we should keep to higher standards than ("first look" or "apparently similar").
What do you think. ?