Return-Path: X-Original-To: apmail-openoffice-dev-archive@www.apache.org Delivered-To: apmail-openoffice-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D0B7818113 for ; Tue, 13 Oct 2015 04:01:44 +0000 (UTC) Received: (qmail 42333 invoked by uid 500); 13 Oct 2015 04:01:38 -0000 Delivered-To: apmail-openoffice-dev-archive@openoffice.apache.org Received: (qmail 42255 invoked by uid 500); 13 Oct 2015 04:01:38 -0000 Mailing-List: contact dev-help@openoffice.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openoffice.apache.org Delivered-To: mailing list dev@openoffice.apache.org Received: (qmail 42239 invoked by uid 99); 13 Oct 2015 04:01:37 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2015 04:01:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 628B5C2DD5 for ; Tue, 13 Oct 2015 04:01:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id I3QVSjRn7Q28 for ; Tue, 13 Oct 2015 04:01:23 +0000 (UTC) Received: from cdptpa-oedge-vip.email.rr.com (cdptpa-outbound-snat.email.rr.com [107.14.166.227]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 76EF320D30 for ; Tue, 13 Oct 2015 04:01:22 +0000 (UTC) Received: from [65.185.58.75] ([65.185.58.75:40282] helo=[10.5.0.2]) by cdptpa-oedge02 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id 38/38-25955-A028C165; Tue, 13 Oct 2015 04:01:15 +0000 Reply-To: andrew@pitonyak.org Subject: Re: [API] Priority Problem with AND and OR References: <561C0C9D.1090300@gmx.net> <561C4D38.9090104@gmail.com> To: dev@openoffice.apache.org From: Andrew Douglas Pitonyak Message-ID: <561C820A.5040902@pitonyak.org> Date: Tue, 13 Oct 2015 00:01:14 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <561C4D38.9090104@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-RR-Connecting-IP: 107.14.168.130:25 X-Cloudmark-Score: 0 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++ http://en.cppreference.com/w/c/language/operator_precedence Java is the same https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html Even VBA gives AND higher precedence than OR https://msdn.microsoft.com/en-us/library/fw84t893.aspx General comments on what is expected is listed here: https://en.wikipedia.org/wiki/Order_of_operations 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 http://www.p-roocks.de/truthtable2.php you can create "tables of > truth" (Wahrheitstabellen) for logical expressions like "A or B and C" > and more complex ones. > >> cases (because TRUE Or () = TRUE): >> bResult = TRUE >> But you will get >> TRUE Or FALSE And TRUE = (TRUE Or FALSE) And TRUE = TRUE >> TRUE Or TRUE And FALSE = (TRUE Or TRUE) And FALSE = FALSE >> >> 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: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org For additional commands, e-mail: dev-help@openoffice.apache.org