lua-users home
lua-l archive

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


On Fri, Sep 16, 2016 at 2:38 PM, Soni L. <fakedme@gmail.com> wrote:
> A boolean is a 1-bit number. An integer is a 32- or 64-bit number.
>
> Bitwise not applies to both.
>
> Bitwise not on a boolean is ((~TRUE)&1), which produces the same value as
> (!TRUE).
>
> And Rust uses ! for both bool not and bitwise not, granted it does have a
> complex and potentially turing-complete type system.

A boolean is not a 1-bit number in Lua. You can't perform arithmetic
with true and false. Furthermore, integer 0 does not evaluate as
boolean false in Lua.

You could say a boolean CAN be represented as a 1-bit number, but
that's incompatible with everything else booleans do differently in
Lua.

(Aside: Booleans are 1-bit numbers in C99 and C++, but the ~ operator
doesn't operate on anything smaller than an int, so in those languages
~true != !true.)

/s/ Adam