Re: 'C' Operators precedence

David Todd (dtodd@bbn.com)
Wed, 20 May 1998 14:23:07 -0400


Huh? Sure, you have to evaluate the function before you can perform the
addition. I'm not disputing that.

But understand that the reference to a is also an implicit operation. The
operation is (get this value).

To perform the addition operation, you must get all your operands, which in
some cases means evaluating functions or operations with higher precedence.

A logical algorithm might go:

given b = a + f()

load a in the accumulator
call the function f() { during which the accumulator and all the other
registers are pushed onto the stack for safety... } and place the returned
value in a register X.

add X to the accumulator.

Even if f() modifies a, it didn't modify the accumulator, so the effect is not
noticed.

Note that while all addends must be rendered into an add-able form before
evaluation, the order should be irrelevant if it is in fact commutative. The
order in which they are evaluated (read turned into numbers that can be added)
is therefore subject to the whim of the compiler implementor, who might have
great reasons for doing it out of the expected order.

-- 
Hacksaw = David Charles Todd
GTEI-BBNT = Hacksaw's Employer
Hacksaw's Opinions != GTEI-BBNT's Opinions
Linux understands you.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu