lua-users home
lua-l archive

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

Currently the concatenation operator has higher precedence than the
binary bitwise operators (<< >> & | ~). This is very unexpected, since
the addition and multiplication operators have higher precedence than
the concatenation operator. It'd make more sense and be more
consistent if the precedence of the concatenation operator was below
the bitwise operators. Lua 5.4 removed support for implicit
conversions with strings as arguments to bitwise operators, so string
concatenation as an operand of a bitwise operator will now error. Code
which overloads the concatenation or bitwise operators and uses them
such that changing the precedence will alter their behavior is likely
very rare.

Another useful change to the operator precedence is making relational
comparisons (< > <= >=) have higher precedence than equality
comparisons (== ~=). This would be less impactful than changing
concatenation precedence, but would be beneficial in a few cases. An
example would be a<0 == b<0 to see if both are negative or both are
nonnegative, which I have done a few times before. This shouldn't be a
breaking change, except for the very odd case of doing an equality
comparison on the left side of a relational comparison, and
overloading relation comparison with a boolean on the left hand side.
Even if this is seldom beneficial, I think that this change is still

I think that these changes would make the language better, and should
have minimal incompatibility issues.