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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8c87bf30faa2b6b X-Google-Attributes: gid103376,public From: rgilbert@unconfigured.xvnews.domain (Bob Gilbert) Subject: Re: [Q] To initialise or not. Date: 1996/05/02 Message-ID: <4makif$q3c@theopolis.orl.mmc.com>#1/1 X-Deja-AN: 152859415 references: <75602294@dorunth.hb.north.de> organization: The unconfigured xvnews people reply-to: rgilbert@unconfigured.xvnews.domain newsgroups: comp.lang.ada Date: 1996-05-02T00:00:00+00:00 List-Id: In article <75602294@dorunth.hb.north.de>, "Thorsten Behrens" writes: > Captain, bei Sternzeit Fri, 26 Apr 1996 18:55:28 GMT empfingen wir folgende > Nachricht von Robert A Duff: > > > In the above, I would *not* write "X: Integer := 0;". > > This initialization would indeed make no sense. But in the example above > (and in many similar cases) you could have used: > > declare > X : INTEGER > := 12; > -- 'X' is initialized to 12 here because ... > -- It will be changed to '13' under the following circumstances ... > -- in the code piece following. > begin > if not ... then > X := 13; > end if; > ... -- some reads of 'X' You could get fully carried away and do something like: function Init_X(Condition : BOOLEAN) return INTEGER is type VALUES_LIST is array (BOOLEAN) of INTEGER; Init_Values : constant VALUES_LIST := (False => 13, True => 12); begin return Init_Values(Condition); end Init_X; declare X : INTEGER := Init_X(); begin ... -- some reads of 'X' -Bob