Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!husc6!necntc!cullvax!drw From: drw@cullvax.UUCP Newsgroups: comp.lang.c Subject: short circuit evaluation Message-ID: <903@cullvax.UUCP> Date: Wed, 11-Mar-87 14:30:53 EST Article-I.D.: cullvax.903 Posted: Wed Mar 11 14:30:53 1987 Date-Received: Thu, 12-Mar-87 20:22:14 EST Organization: Cullinet Software, Inc., Westwood, MA Lines: 28 john@viper.UUCP (John Stanley) writes: > If you have three expressions: > 1: a+b+c > 2: (a+b)+c > 3: a+(b+c) > all three of them should not be evaluated the same way. Greg implys that > they should be. This is not so. When an equation contains '(' and ')' > it intentionaly (and explicitly) defines the parse tree structure that will > result. The statement "redundant ()'s grow in C like mushrooms" may be true, > but it doesn't give anyone the right to arbitrarily ignore explicit cues > to the compiler. When I don't care, I don't use them. When I do, I do > so for a reason.......... Read the opening paragraphs of section 3.3 of X3J11. The compiler is allowed to re-associate multiples uses of *, +, &, ^, and |. If you want to prevent this, you have to write: +(a+b) + c, etc. The parentheses you wrote aren't explicit cues to the compiler, by definition. (*Why* X3J11 did this is another question...) Dale -- Dale Worley Cullinet Software UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw ARPA: cullvax!drw@eddie.mit.edu Un*x (a generic name for a class of OS's) != Unix (AT&T's brand of such)