From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!DCA-EMS.ARPA!jmoody From: jmoody@DCA-EMS.ARPA (Jim Moody, DCA C342) Newsgroups: comp.lang.ada Subject: Re: Side Effects Message-ID: <8804112114.AA03398@ajpo.sei.cmu.edu> Date: 11 Apr 88 20:00:12 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: 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.