lua-users home
lua-l archive

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

On 23 Oct 2011, at 18:31, Dirk Laurie <> wrote:
> What you need metamethods for is not `and`, `or` and `not`.  It's metamethods
> for `&`, `|` and `~` (or `!`), which are not in Lua yet.  They'd be
> nice to have,
> being predefined for boolean and number (i.e., bit32,bor
> and bit32.bnot)
> why not binary `#` for bit32.bxor while we're about it; one day when we get an
> arbitrary length `bit` library they could be defined for strings too.

Good plan. I recommend using the same operator for unary NOT and binary XOR, by analogy with negation and subtraction. ~ is a good choice given its use in the ~= operator and in C.

f.anthony.n.finch  <>