[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Array Logical Operators
- From: Tony Finch <dot@...>
- Date: Tue, 25 Oct 2011 02:06:27 +0100
On 23 Oct 2011, at 18:31, Dirk Laurie <firstname.lastname@example.org> 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.band, 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 <email@example.com> http://dotat.at/