Answering this question, I found that in:
echo 1 2 | awk '{print $(expression)}' the return value of expression is unspecified. It can lead to confusion, as if expression is an uninitialized variable, should $(expression) return 0 (as evaluated in numeric context) or return empty string "" ( as evaluated in string context) or raise an error.
Since when field variables were defined as:
Field variables shall be designated by a '$' followed by a number or numerical expression
Why POSIX left the return value of any expression follow $ unspecified? Is it a historical reason or something else?
$(…), but only if…evaluates to a nonnegative ineteger. Are you asking why the value of an expression consisting of an undefined variable is left unspecified? (That's what you seem to be asking, but then what does the$operator have to do with it?)Field variables shall be designated by a '$' followed by a number or numerical expression. The effect of the field number expression evaluating to anything other than a non-negative integer is unspecified; uninitialized variables or string values need not be converted to numeric values in this context. Then the expression follow$need not be converted to numeric values, it means$(expression)unspecified, doesn't it?$wasn't defined to have numeric or string context, that's how$operator affect.