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: 10 Apr 93 09:39:07 GMT From: munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!usenet@tcgould.tn.c ornell.edu (Andrew Dunstan,,2285592,) Subject: Re: and then Message-ID: <1q64jr$o39@huon.itd.adelaide.edu.au> List-Id: >>From article <1993Apr9.180808.19494@scf.loral.com>, by bashford@srs.loral.com (Dave Bashford): > In article <1q29bd$7d8@huon.itd.adelaide.edu.au> andrewd@cs.adelaide.edu.au w rites: >>>From article <1993Apr7.162133.3564@nosc.mil>, by sampson@nosc.mil (Charles H. Sampson): >> >> >>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. > > Are there "desired side-effects" ? > Certainly. One classic example should suffice. Since Ada does not have "own" variables, a random number generator function in Ada will normally have the desired side-effect of changing its seed. Of this would best be done by hiding the seed in a package, where nothing but the function could change the seed, but that is another issue. Ada is NOT a functional language - it is procedural, and side-effects are common. None of this is to deny that over-use of side effects is bad practice. It is, and as a teacher I have tried to encourage students to avoid side-effects wherever possible. (Note the qualification). Interestingly, functions in protected objects in Ada9X are to be prohibited from having side-effects which alter the protected data (thus permitting the optimisation of allowing several such functions to be active at one time). # Andrew Dunstan # There's nothing good or bad # # net: # # # adunstan@steptoe.adl.csa.oz.au # but thinking makes it so. # # or: andrewd@cs.adelaide.edu.au # #