|
On 11/12/2011 15.27, Roberto Ierusalimschy wrote:
I've read the refman several times but strangely I only noticed recently that the precedence table in section 3.4.7 (I'm referring to 5.2.0, but the table is the same in 5.1.4) doesn't mention the following operators: function call "()" array indexing "[]" field access "." method call ":" Not that this prevented me to be confused writing code, but somehow I subconsciously applied java/C/C++-like precedence rules for those and got away with it (I suppose that those operators have the highest precedence in Lua too). I'm I missing something? Is there a reason to omit them?The grammar gives the precedence for them. The other operators all apply to 'exp'; these apply to a 'prexifexp', which cannot contain binary or prefix operators.
Ah! So the table is indirectly completing the information given by the grammar and clarifies that "It does not describe operator precedences." sentence at the top of it. Ok for the rationale then.
Nevertheless I find it could be rather misleading for a beginner looking for the "classic" precedence table covering all operators. As it is now, the information is split in an odd way (for a reference manual, I mean) between that table and the grammar.
Moreover that sentence could mislead the beginner even more: if he reaches for the grammar trying to infer the precedence of operators, he is being told upfront that the information he is looking for is not there, so he could go looking for the precedence table and that table won't give the full information either.
-- Roberto
Thanks! -- Lorenzo