From: "M. Edward (Ed) Borasky" Date: 2006-08-27T11:41:36+09:00 Subject: Re: and and or priority Matthew Smillie wrote: > On Aug 26, 2006, at 16:16, David Vallner wrote: > >> Pavel Smerk wrote: >>> David Vallner wrote: >>>> Pavel Smerk wrote: >>>> >>>>> OMG! >>>>> >>>>> Why the and and or operators have the same priority? Unlike && and >>>>> || and also unlike the most of, or maybe all, other languages and >>>>> conventions? >>>>> >>>>> (Yes, long time spent on that now, who would expect such a >>>>> curiosity...) >>>>> >>>>> Thanks for explanation, if there is any, >>>>> >>>>> P. >>>>> >> >> For what it's worth though, since most programmers DO expect >> mathemathical rules to hold in programming languages, for the sake of >> consistency, I agree that the and should bind more tightly than or now >> that that's been brought up. > > Is that actually a mathematical rule, though? I don't remember as such > from any math or logic that I know, and poking around through my old > textbooks made no mention of binding or precedence of logical > operations; the closest thing being a statement that parentheses are > required to avoid ambiguity when mixing and and or in one statement, at > least slightly implying that there is no 'order of operations'. > > If anyone has a reference either way on this, I'd be curious to see it. > > matthew smillie. > > My rather dim recollection is that computer jocks forced "and" to bind tighter than "or" and "not" to bind tighter than "and" just so it *was* defined. Only in programming (and logic design) do you usually find Boolean expressions complicated enough for operator precedence to matter. :) Meanwhile, the logicians pretty much abandoned parentheses for Polish (prefix) notation. And of course, the computer jocks, not to be outdone, invented *reverse* Polish notation. :)