comp.lang.ada
 help / color / mirror / Atom feed
From: rgilbert@unconfigured.xvnews.domain (Bob Gilbert)
Subject: Re: [Q] To initialise or not.
Date: 1996/05/02
Date: 1996-05-02T00:00:00+00:00	[thread overview]
Message-ID: <4makif$q3c@theopolis.orl.mmc.com> (raw)
In-Reply-To: 75602294@dorunth.hb.north.de


In article <75602294@dorunth.hb.north.de>, "Thorsten Behrens" <thorsten.behrens@dorunth.hb.north.de> 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(<condition>);
    begin
      ...  -- some reads of 'X'

-Bob






  parent reply	other threads:[~1996-05-02  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-25  0:00 [Q] To initialise or not JP Thornley
1996-04-26  0:00 ` Theodore E. Dennison
1996-04-26  0:00   ` Robert A Duff
1996-04-27  0:00     ` Thorsten Behrens
1996-04-28  0:00       ` Robert Dewar
1996-04-30  0:00       ` mjp
1996-05-02  0:00       ` Bob Gilbert [this message]
1996-04-26  0:00 ` Ken Garlington
1996-04-26  0:00 ` Robert I. Eachus
1996-04-26  0:00 ` Ken Garlington
1996-04-26  0:00   ` Robert A Duff
1996-04-27  0:00   ` Robert Dewar
1996-04-27  0:00     ` Robert A Duff
1996-04-27  0:00 ` Robert Dewar
replies disabled

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