openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Douglas Pitonyak <>
Subject Re: [API] Priority Problem with AND and OR
Date Tue, 13 Oct 2015 04:01:14 GMT
Guenter, although you are correct with respect to Basic as implemented 
in AOO (and you stated it very well... I enjoyed your post), I am not 
aware of any other computer language where this is true. For example:

C and C++

Java is the same

Even VBA gives AND higher precedence than OR

General comments on what is expected is listed here:

It is noted that APL, Smalltalk, and Occam do not have operator 
precedence. Can't say I have used APL in years (like 25 to 30 years). I 
have not used the other two.

The real question becomes.... should it be changed to follow expected 
mathematical norms (breaking all existing correct code and fixing all 
broken code where people assumed it was done in the generally accepted 
way). I am glad I need not make that call.

On 10/12/2015 08:15 PM, Guenter Marxen wrote:
> Hi,
> Am 12.10.2015 um 21:40 schrieb Mathias Röllig:
>> ...
>> What do you expect?
>> For logical operations AND is equivalent to * and OR is equivalent to +.
> no, that's not true. AND and OR have the same priority, just as * and 
> / (division). (* and / have a higher priority than + and -.)
>> AND should have a higher priority than OR, so I would expect in both
> Expressions have to be evaluated from left to right with respect to 
> priority and parenthesis.

Only for those specific operators. And the complaint was that your 
statement is unexpectedly true.

> "and" and "or" are binary operators. Therfore your examples can be 
> written as "A or B" where "B = (C and D)". If you write your example as
> "A or (C and D)" then it is the same and everyone sees immediatly, how 
> it is evaluated.

I wrote an implementation for a proposed international standard in 
Fortran 90 many years back.... It was suggested that I assume that 
people would not know precedence rules so that I should use parenthesis 
for all statements.... and that I should avoid things like ternary 
operators since beginning programmers may not know what they were.

> In both cases, the result is TRUE, because
> "TRUE or anything" is TRUE, just as "TRUE or (anything)".
> "(A or B) and C" is totally different.
> On you can create "tables of 
> truth" (Wahrheitstabellen) for logical expressions like "A or B and C" 
> and more complex ones.
>> cases (because TRUE Or (<anything>) = TRUE):
>> bResult = TRUE
>> But you will get
>> Is there any explanation that AND and OR have (and should have) the same
>> priority?
> It is as it is!
You are correct in that!

Andrew Pitonyak
My Macro Document:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message