lua-users home
lua-l archive

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


On 05/21/2018 11:47 PM, Egor Skriptunoff wrote:
> The problem arises because in Lua negation operator is "not commutative"
> with modulo:
> (-a) % b ~= - (a%b)
>
> That's why in Lua we have an unpleasant surprise:
> - a%m - b%n ~= - b%n - a%m> It's looks very weird.
> That should be an equality as in all other programming languages.

Probably in that languages negation operator _is_ commutative:

-(a % b) == (-a) % b

Lua 5.3 has four unary operators: "#", "~", "-", "not".
Lowering priority of "-" looks inconsistent.
Lowering priority of all unary operators hurts more than cures.

-- Martin