comp.lang.ada
 help / color / mirror / Atom feed
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
Date: 10 Apr 93 09:39:07 GMT	[thread overview]
Message-ID: <1q64jr$o39@huon.itd.adelaide.edu.au> (raw)

>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   #                                 #

             reply	other threads:[~1993-04-10  9:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-04-10  9:39 munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!usenet [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-04-12 18:38 and then Charles H. Sampson
1993-04-12 13:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!noc.n
1993-04-11  3:55 Michael Feldman
1993-04-10 19:52 Alex Blakemore
1993-04-10 15:43 Dik T. Winter
1993-04-10 15:36 Dik T. Winter
1993-04-10  1:03 Charles H. Sampson
1993-04-09 18:08 Dave Bashford
1993-04-09 14:06 Dan Rittersdorf
1993-04-08 22:35 Andrew Dunstan,,2285592,
1993-04-08 22:28 Alex Blakemore
1993-04-08 19:03 Art Duncan
1993-04-08 16:18 Charles H. Sampson
1993-04-08 15:34 Christopher J. Henrich
1993-04-08 12:21 enterpoop.mit.edu!usc!cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner
1993-04-07 22:58 Mark Lundquist
1993-04-07 21:07 Ray Harwood -- Data Basix: (602)721-1988
1993-04-07 16:21 Charles H. Sampson
1993-04-07 12:42 Robert Firth
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox