Portable Languages (was: Expression sequencing query)
Jason Zions
jason at hpcnoe.UUCP
Fri Oct 17 03:33:21 AEST 1986
dik at mcvax.uucp (Dik T. Winter) writes:
> And so should it. Once I required the expression (A - B) - C evaluated
> exactly that way. It didn't do so. However, after removing the
> parenthesis it was evaluated the way I wanted. Counterintuitive?
Not counterintuitive - BROKEN. Although C may rearrange the order of
evaluation with respect to + * & ^ and |, it may not do so w.r.t. operators
which aren't associative and commutative.
Rearranging (A - B) - C is just plain wrong.
References:
H&S Section 7.11, page 190
K&R Section 2.12, page 49
Note that both references state that reordering is permitted only for the
associative and commutative operators; they do not mention the names of the
operators for which reordering is forbidden.
--
This is not an official statement of Hewlett-Packard Corp., and does not
necessarily reflect the views of HP. It is provided completely without warranty
of any kind. Lawyers take 3d10 damage and roll a saving throw vs. ego attack.
Jason Zions Hewlett-Packard
Colorado Networks Division 3404 E. Harmony Road
Mail Stop 102 Ft. Collins, CO 80525
{ihnp4,seismo,hplabs,gatech}!hpfcdc!hpcnoe!jason
More information about the Comp.lang.c
mailing list