7

If I write the expression,

if not (expr1 or expr2) then value

I get the following warning from FSharpLint, In F# code, use 'e1 || e2' instead of 'e1 or e2'.

Why is using || preferred over using or? I want to write idiomatic code, but this appears to me to degrade readability. I really like the readability of the not function over !. the above example expression reads nicer and is much more declarative than the C# counterpart,

if (!(expr1 || expr2)) { return value; }

So why regress the readability improvement by suggesting double pipes instead of or?

1 Answers1

6

According to the FSharpLint folks, it's not a Lint warning; it's a warning emitted by the F# compiler.

It's probably there because or doesn't have a corresponding and counterpart. There is an and keyword, but it's not used for boolean operations, so you have to use && anyway, which means its better to use || for consistency.

Robert Harvey
  • 200,592