lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On 05/01/2015 14:22, Roberto Ierusalimschy wrote:
Since v5.3 is close to finalization, I just throw in a suggestion about
something (trivial) that has always bugged me: can we have the table of
operator precedence reversed (section 3.4.8)? Not a big deal, but every
time I look at it it feels upside-down. In every refman I've seen,
higher precedence operators are placed, well, higher. Not so important,
but I find it distracting (my brain automatically searches in the
"wrong" direction - but maybe it's just me).

At least Python lists them like Lua:

   https://docs.python.org/2/reference/expressions.html#operator-precedence

Ouch! My memory failed me! I haven't touched almost any line of Python since I discovered Lua :-) and I practiced it only for some months before then. I was sure it was in the reverse order.

My copy of Stroustrup (C++) and K&R ISO C both have the table in the reverse direction (just double checked now ;-).

In Java the language specification has no table, and the precedence is expressed in the grammar, the same as ECMAscript (which IIRC is the specification for Javascript), but I'm sure I've seen some reputable references with a spelled-out table in the order I remembered:

For Javascript see [1], and this is the Java tutorial [2].

For C++ and C see also [3] and [4].

But, as I said, not a big problem (as long as the table remains short :-)

-- Lorenzo


[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

[2] http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html

[3] http://en.cppreference.com/w/cpp/language/operator_precedence

[4] http://en.cppreference.com/w/c/language/operator_precedence


-- Roberto