Boolean operations in F#: spec gone bad

The F# language specification does not talk much about Boolean operations, but it does say that ~~~ is op_LogicalNot and &&& is a “bitwise and”, also called land. The && operator is said to be an “address-of” expression.

In reality if ~~~condition does not work: it complains that bool does not define operator ~~~. What works is if not condition.

If if a &&& b does not work either. What works is if a && b. So much for the address-of operator. I am not sure why it is not possible to keep the spec straight and why I should second-guess such simple things…

Posted in


  1. Hi Ivan,
    The operators that you have looked for are actually logical bitwise operators rather than conditions. That’s why the bool type does not support them, they are actually operation that evaluate to another constant in that case a number. Just like + – arithmetic operation, but they are logical operations. The equivalent of | & in C# world if you will.
    For boolean “or and” you need to use && || not as you have figured out.
    I’m sure we will see wonders when the CTP comes along as each new version of F#, so I disagree with most of your posts because of the continous evolution of the language for good.


  2. Hi,

    ~~~ works on numbers: ~~~ 10 = -11
    It’s the same for bitwise operators: 7 ||| 15 = 15 ; 7 ||| 16 = 23.

    For boolean operations, you should use ||, && and not.


Leave a Reply

Your email address will not be published. Required fields are marked *