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, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.ada Subject: Re: Side effect Message-ID: <863@cresswell.quintus.UUCP> Date: 9 Apr 88 06:58:07 GMT References: <14425@uflorida.cis.ufl.EDU> Organization: Quintus Computer Systems, Mountain View, CA List-Id: In article <14425@uflorida.cis.ufl.EDU>, lius@beach.cis.ufl.edu (Scott Liu) writes: > ID: INTEGER := 0; > function NEXT return INTEGER is > begin > ID := ID+1; > return ID; > end; > declare > type BIG is record X: INTEGER := NEXT; end record; -- ??? > A: array (1..5) of BIG; -- ??? {A is (1,2,3,4,5), not the expected (1,1,1,1,1).} This is the way ADA is generally supposed to work. For example, X, Y: INTEGER := NEXT; is defined to be equivalent to X: INTEGER := NEXT; Y: INTEGER := NEXT; In general, what matters is not how many copies of an initialiser you write, but how many things are initialised: an expression is evaluated for _each_ variable it is used to initialise. It's not the way I'd prefer it, but at least it is consistent and predictable. LRM 3.7 paras 5 and 11. LRM 3.2.1 (note para 6).