comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: "out" and  "in out"
Date: Mon, 26 Jul 2004 06:00:31 -0500
Date: 2004-07-26T06:00:31-05:00	[thread overview]
Message-ID: <ot5Nc.16655$QO.11174@bignews5.bellsouth.net> (raw)
In-Reply-To: 4104d5de@dnews.tpgi.com.au


"zork" <zork@nospam.com> wrote in message news:4104d5de@dnews.tpgi.com.au...
> Hi i found the following explaination:
>
> In Ada, "in" parameters are similar to C++ const parameters. They are
> effectively read-only within the scope of the called subprogram.
> Ada "in out" parameters have a reliable initial value (that passed
> in from the calling subprogram) and may be modified within the scope
> of the called procedure. Ada "out" parameters have no reliable
> initial value, but are expected to be assigned a value within the
> called procedure.
>
> What does "have no reliable initial value" mean when considering the "out"
> parameter?
It means that wihn the procedure "modify," if youo attempt to read the
value of the formal parameter "s1," it would "have no reliable initial
value."
It has no bearing on the value of the actual parameter "s."
>
> By chance I created a small program as follows:
>
> ===========
> s : string := "CAT";
>
> procedure modify ( s1 : out string ) is
> begin
>    s1(2) := 'U';
> end modify;
>
> ..
>
> put ( modify(s) );
> ===========
>
> now I get as a result "CUT", and i dont understand why i get this result.
> Doesnt the "out" specify that its initial value isnt passed in via the
> parameter? But it seems to be passed in the above. In fact the "out" is
> acting like an "in out". I am a little confused. Could someone shed some
> light on this?
>
> Many thanks!
>
> zork
>
>
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
>
>




  reply	other threads:[~2004-07-26 11:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-26  9:58 "out" and "in out" zork
2004-07-26 11:00 ` David C. Hoos [this message]
2004-07-26 11:30 ` Martin Krischik
2004-07-26 14:46 ` Nick Roberts
2004-07-28 14:07   ` zork
  -- strict thread matches above, loose matches on Subject: below --
2004-07-26 10:54 Christoph Karl Walter Grein
2004-07-26 14:16 ` Marc A. Criley
replies disabled

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