I'm a bit confused by the following:
$ echo foo bar baz | awk '{printf "%d:", NF--; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; $NF=""; NF -= 1; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; $(NF--)=""; print NF}'
3:3
I see the same behavior in awk version 20070501 (macos) and GNU Awk 4.0.2. Why does the post-decrement of NF in the 3rd case not apply? Is that behavior expected, mandated by a standard, or a quirk of the implementation?
EDIT by Ed Morton: FWIW I'd find the following a more compelling example:
$ echo foo bar baz | awk '{printf "%d:", NF; NF--; $NF=""; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; --NF; $NF=""; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; $NF=""; NF--; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; $NF=""; --NF; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; $(--NF)=""; print NF}'
3:2
$ echo foo bar baz | awk '{printf "%d:", NF; $(NF--)=""; print NF}'
3:3
with the question being why does the last example (post-decrement with assignment) behave differently from all of the other cases, regardless of which one you think it should be equivalent to.