comp.lang.ada
 help / color / mirror / Atom feed
From: "zork" <zork@nospam.com>
Subject: "out" and  "in out"
Date: Mon, 26 Jul 2004 19:58:22 +1000
Date: 2004-07-26T19:58:22+10:00	[thread overview]
Message-ID: <4104d5de@dnews.tpgi.com.au> (raw)

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?

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






             reply	other threads:[~2004-07-26  9:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-26  9:58 zork [this message]
2004-07-26 11:00 ` "out" and "in out" David C. Hoos
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