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.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!uflorida!beach.cis.ufl.edu!lius From: lius@beach.cis.ufl.edu (Scott Liu) Newsgroups: comp.lang.ada Subject: Side effect Message-ID: <14425@uflorida.cis.ufl.EDU> Date: 9 Apr 88 02:05:54 GMT Sender: news@uflorida.cis.ufl.EDU Reply-To: lius@ufl.edu (Sying-Syang Liu) Organization: UF CIS Department List-Id: Recently, I wrote an Ada program with side effect on a function, called NEXT, which is used on both type and variable declarations. I got very weird program output when I ran it using TeleSoft Ada compiler. Is this a compilation error or compiler-dependent feature? Thanks for your comments. Sying-Syang Liu Dept. of Computer and Information Sciences University of Florida UUCP: {ihnp4,rutgers}!codas!ufcsv!lius Internet mail: lius@ufl.edu ------ Program source ------------- with TEXT_IO; use TEXT_IO; procedure SET2 is ID:INTEGER:=0; function NEXT return INTEGER is begin ID:=ID+1; return ID; end; begin declare type BIG is record X:INTEGER:=NEXT; end record; -- ??? A:array (1..5) of BIG; -- ??? B:integer:=NEXT; begin for I in A'RANGE loop PUT(INTEGER'IMAGE(A(I).X)); end loop; PUT_LINE(INTEGER'IMAGE(B)); end; end; ----- Program output ----- 1 2 3 4 5 6 -------------------------- Note: I expected to have the output 1 1 1 1 1 2