From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 9 Apr 93 18:08:08 GMT From: scf16!bashford@ford-wdl1.arpa (Dave Bashford) Subject: Re: and then Message-ID: <1993Apr9.180808.19494@scf.loral.com> List-Id: In article <1q29bd$7d8@huon.itd.adelaide.edu.au> andrewd@cs.adelaide.edu.au wri tes: >>From article <1993Apr7.162133.3564@nosc.mil>, by sampson@nosc.mil (Charles H. Sampson): > >[ should we always use short-circuit boolean forms?] > >So, the compiler writers are correct in not attempting to cast >non-short circuit forms to short-circuit evaluation. > >There could well be cases where evaluation of both operands is wanted >(if evaluation of one or both has a desired side-effect). If so, >"optimising" evaluation of one away is highly undesirable. I can't believe my eyes - "desired side-effect" in Ada ? Several people have mentioned side-effects as a reason not to optimize boolean expressions. I thought one of the guiding principles of good s/w engineering was to minimize or eliminate side-effects. The only reason I can think of not to optimize to short circuit forms is to catch undesired side-effects. I would've thought that with the number of purists out there, as the height of the flames on this news group would suggest, someone would've mentioned this before ? Are there "desired side-effects" ? Should compilers optimize when, because of poor programming, the behaviour of the program might change ? ("poor programming" is too strong, read "less than ideal programming") Apparently, the LRM says no. I don't remember the specific reference, but it says something about "optimizing should never change the semantics of the program." -- db bashford@srs.loral.com (Dave Bashford, Sunnyvale, CA)