comp.lang.ada
 help / color / mirror / Atom feed
* Re: Side Effects
@ 1988-04-11 20:00 Jim Moody, DCA C342
  1988-04-14  7:55 ` Matti J{rvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Moody, DCA C342 @ 1988-04-11 20:00 UTC (permalink / 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1988-04-14  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1988-04-11 20:00 Side Effects Jim Moody, DCA C342
1988-04-14  7:55 ` Matti J{rvinen

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