Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math.independent

Topic: Reason for operator precedence
Replies: 15   Last Post: Mar 15, 2006 8:56 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Ben Rudiak-Gould

Posts: 210
Registered: 2/2/05
Re: Reason for operator precedence
Posted: Mar 14, 2006 11:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Tony wrote:
> I was wondering what the reason is for having multiple levels of operator
> precedence?
>
> Phrased another way, why is it that we don't just evaluate everything from
> left to right?


Your use of "just" suggests that you think that there's already a rule that
unparenthesized expressions are evaluated from left to right in the absence
of overriding precedence rules. Actually there's no such rule. The
expression "x - y + z" is a shorthand for "x + (-y) + z", where (-y) denotes
the additive inverse of y. The additions may be done in any order because
addition is associative. A mathematician would never write an expression
like (x # y # z) if # was not associative, because that would be ambiguous.

The notion of "left associative" and "right associative" infix operators is
peculiar to computer science, as far as I know. It shows up mostly in
programming language grammars, but also in the lambda calculus, where xyz
means (xy)z, which is different from x(yz). If there are examples of this
kind of thing outside of computer science, I'd be interested in hearing
about them.

-- Ben



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.