Logical statements in @Formula

Have you noticed, that some of the logical statements in @Formula language are pocessed in different way than “mathematical logic”. For example:

a | b & c is for Lotus (a | b) & c, which is probably wrong. Should be a | (b & c), because & is stronger than |. Am I wrong?

Subject: Logical statements in @Formula

While the rules are not as other languages implement them, it is working as documented. The logical operators all have the same Precedence level, so they are evaluated in sequence.

Personally, I always use parentheses to enforce evaluation sequence, as it helps in understanding what the intent was.

FORMULA LANGUAGE

Operators and precedence

The table below lists the operators and their precedence, where 1 is the highest precedence.

Operator

Operation

Precedence

:=

Assignment

NA

List subscript

1

:

List concatenation

2

Positive

Negative

3

**

/

*/

Multiplication

Permuted multiplication

Division

Permuted division

4

*+

*-

Addition, concatenation

Permuted addition

Subtraction

Permuted subtraction

5

=

*=

<>

!=

=!

<

*<>

<

*<

*>

<=

*<=

=

*>=

Equal

Permuted equal

Not equal

Not equal

Not equal

Not equal

Permuted not equal

Less than

Permuted less than

Greater than

Permuted greater than

Less than or equal

Permuted less than or equal

Greater than or equal

Permuted greater than or equal

6

!

&

|

Logical NOT

Logical AND

Logical OR

7

Subject: RE: Logical statements in @Formula

Well, yes - parentheses can be useful, but sometimes it is better for me not to have several parentheses in a row - like ))).

Thanks for info.

Subject: RE: Logical statements in @Formula

Never worked in LISP then?! :slight_smile:
I’ve seen it pointed out before on this form that precedence for “and” and “or”, and while I agree with you it “should” work, the simple fact is, you don’t know who may look at your code in the future and many not know these rules … So brackets are probably always a good idea.