Why "and and or" Have Different Association from "&& and ||"?

Hi,

I searched through the previous discussions on this subject, but I could
not find an answer to this question:

We know that “&& and ||” have higher precedence than “and and or”. But
while “&&” has higher precedence than “||”, why “and” and “or” have the
same precedence, with left to right evaluation, I guess?

Regards,

Bill

Hi,

···

In message “Why “and and or” Have Different Association from “&& and ||”?” on 02/09/24, William Djaja Tjokroaminata billtj@y.glue.umd.edu writes:

I searched through the previous discussions on this subject, but I could
not find an answer to this question:

We know that “&& and ||” have higher precedence than “and and or”. But
while “&&” has higher precedence than “||”, why “and” and “or” have the
same precedence, with left to right evaluation, I guess?

Because english words “and” and “or” does not have precedence order.

						matz.

On the other hand, the english word “or” actually means “^” (exclusive
or) rather than “||” (inclusive or). :slight_smile:

Cheers,
Nat.

···

On Tue, 2002-09-24 at 15:46, Yukihiro Matsumoto wrote:

In message “Why “and and or” Have Different Association from “&& and ||”?” > on 02/09/24, William Djaja Tjokroaminata billtj@y.glue.umd.edu writes:

We know that “&& and ||” have higher precedence than “and and or”. But
while “&&” has higher precedence than “||”, why “and” and “or” have the
same precedence, with left to right evaluation, I guess?

Because english words “and” and “or” does not have precedence order.


Dr. Nathaniel Pryce, Technical Director, B13media Ltd.
Studio 3a, 22-24 Highbury Grove, London N5 2EA, UK
http://www.b13media.com

Hi,

I tend to agree with Nat, that probably the “English influence” should be
diminished in this respect. Well, in Perl there is some “use
English” module that will make “and” to replace “&&”, etc., but there they
are perfectly equivalent.

In Ruby, I like that “and, or, not” have lower precedence than
the assignments, because in most my code, that is what I want to
accomplish (with assignment being the side-effect). But now, we have to
put the extra parentheses if the “or” is on the left side of the
“and”. Doesn’t this put an extra work on our brain, even for
English-speaking people, as in most other computer languages the
“and” (either in “and”, “&&”, or “.AND.” forms) always has higher
precedence than the “or”?

Regards,

Bill

···

=============================================================================
Nat Pryce nat.pryce@b13media.com wrote:

Because english words “and” and “or” does not have precedence order.

On the other hand, the english word “or” actually means “^” (exclusive
or) rather than “||” (inclusive or). :slight_smile: