lua-users home
lua-l archive

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


On Sun, Apr 8, 2018 at 12:18 AM, Soni "They/Them" L. wrote:

On 2018-04-07 05:34 PM, Albert Chan wrote:
This is legal in Lua, so why not only a __bshr meta method and call
this with a negative shift count for the << operator?
Same reason we have __sub operator (for convenience):

A - B = A + (-B)

A + (-B) is legal in Lua, so why not ...

Why have __add or __unm at all anyway

A + B == A - (0 - B)
-A == (0 - A)

Also why have __mul

A * B == A / (1 / B)

And so on.


Why we have
__band, __bxor, __bor, __bnot
when we could simply have the only boolean operation
__bnand (Sheffer stroke) ?

:-)