And has same precedence as Or
Posted: Mon Aug 16, 2010 2:28 pm
I'm putting this here since it's worthy of discussion, and the ticket isn't a place for discussion.
And being higher than Or and Times/Divide being higher than Plus/Minus is not arbitrary, it's the standand rule for mathematics and for logic, and it's how and C, C++, C#, Python, Perl, Php, Java, Visual Basic, and Eiffel work.
http://en.wikipedia.org/wiki/Logical_connective#Order_of_precedence
'And' has higher precedence than 'or' for the same reason that * has higher precedence than +.
http://mathforum.org/library/drmath/view/52582.html
How is it advantagous is that it doesn't have the disadvantages of turfing conventions from hundreds of years of mathematics and logic and that most programmers know and expect.
In a book on Cobra I'd expect it to appear as a note in a box with a warning icon saying look out!
This was intentional rather than accidental. I don't see that adding another operator precedence level is advantageous, or that you wouldn't want the parens for added clarity. I'll close this ticket unless I'm convinced otherwise.
And being higher than Or and Times/Divide being higher than Plus/Minus is not arbitrary, it's the standand rule for mathematics and for logic, and it's how and C, C++, C#, Python, Perl, Php, Java, Visual Basic, and Eiffel work.
http://en.wikipedia.org/wiki/Logical_connective#Order_of_precedence
Operator Precedence
not 1
and 2
or 3
'And' has higher precedence than 'or' for the same reason that * has higher precedence than +.
http://mathforum.org/library/drmath/view/52582.html
The standard order of operations, or precedence, is expressed in the following chart.
exponents and roots
multiplication and division
addition and subtraction
1. The basic rule (that multiplication has precedence over addition) appears to have arisen naturally and without much disagreement as algebraic notation was being developed in the 1600s and the need for such conventions arose.
How is it advantagous is that it doesn't have the disadvantages of turfing conventions from hundreds of years of mathematics and logic and that most programmers know and expect.
In a book on Cobra I'd expect it to appear as a note in a box with a warning icon saying look out!