comp.lang.ada
 help / color / mirror / Atom feed
From: jmoody@DCA-EMS.ARPA (Jim Moody, DCA C342)
Subject: Re: Side Effects
Date: 11 Apr 88 20:00:12 GMT	[thread overview]
Message-ID: <8804112114.AA03398@ajpo.sei.cmu.edu> (raw)

As two correspondents have noted, Sying-Syang Liu is wrong to expect 
a function with side effects to be called only once when it is an
explicit initialization of a component of a record which is a 
component of an array.
But the situation is even worse than that.
The order in which the components are evaluated is not determined by
the language (LRM 3.2.1(15), last sentence).
So, whereas Liu expected 1,1,1,1,1,2 and got 1,2,3,4,5,6
the compiler could have (without being incorrect) have given 5,4,3,2,1,6
or 1,5,4,2,3,6 or . . . .
What this goes to show is that writing function with side effects is a very,
very risky business in Ada.  Actually, it's a risky business in any language,
but Ada makes the risk explicit.
                                           Jim.

             reply	other threads:[~1988-04-11 20:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-04-11 20:00 Jim Moody, DCA C342 [this message]
1988-04-14  7:55 ` Side Effects Matti J{rvinen
replies disabled

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