Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ihnp4!ptsfa!lll-lcc!seismo!husc6!bacchus!mit-eddie!rutgers!dayton!viper!john From: john@viper.UUCP Newsgroups: comp.lang.c Subject: Re: short circuit evaluation Message-ID: <609@viper.UUCP> Date: Mon, 2-Mar-87 04:59:20 EST Article-I.D.: viper.609 Posted: Mon Mar 2 04:59:20 1987 Date-Received: Wed, 4-Mar-87 19:09:59 EST References: <844@wanginst.EDU> <4700004@uiucdcsm> <4211@utcsri.UUCP> Reply-To: john@viper.UUCP (John Stanley) Organization: DynaSoft Systems Lines: 37 In article <4211@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes: > >It is worth noting at this point that the parentheses '(' and ')' serve >only in the process of converting a linear expression to a tree. Thus >(a+b)*c is different from a+b*c but a+(b+c) can be treated the same as >(a+b)+c. Simply allow your tree to contain a node which forms the sum of >its three, equally ranked, children, and throw in the fact that >redundant ()'s grow in C like mushrooms. Then a+(b+c) should be treated >as a+b+c or SUM(a,b,c). ( I know, there are overflow considerations). > >---------------------------------------------------------------------- >Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg >Have vAX, will hack... The example Greg provides here is misleading. 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.......... Since there is additional, undesireable, and unnecessary overhead in the detection of this SUM(a1,a2,a3...,aN) special case, and since there appears to be little or no advantage to doing so (you have to add them up in -some- order, you might as well let the programmer decide as anyone), why bother? --- John Stanley (john@viper.UUCP) Software Consultant - DynaSoft Systems UUCP: ...{amdahl,ihnp4,rutgers}!{meccts,dayton}!viper!john