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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ec3c155a33990ec6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: "out" and "in out" Date: Mon, 26 Jul 2004 15:46:37 +0100 Message-ID: References: <4104d5de@dnews.tpgi.com.au> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de N0rhljtprUGc7qKcZQY5/QSQdE0tL6KvlIMXI9m26zuutPVlg= User-Agent: Opera M2/7.51 (Win32, build 3798) Xref: g2news1.google.com comp.lang.ada:2400 Date: 2004-07-26T15:46:37+01:00 List-Id: On Mon, 26 Jul 2004 19:58:22 +1000, zork wrote: > ... > 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? Yes, but it doesn't forbid the compiler to (effectively) pass the value in. In practice, this is likely to happen if the parameter is of a composite type (an array or record), because the compiler will probably choose to pass it by reference. > But it seems to be passed in the above. In fact the "out" > is acting like an "in out". Yes. This is permitted. But your program would be wrong to rely upon it. If you were to try: =========== n : integer := 456; procedure modify ( n1 : out integer ) is begin n1 := n1+44; end modify; ... modify(n); put(n); =========== I think you might not get 500 printed out (I don't, running this on GNAT 3.15p on Win XP (and GNAT gives a warning)). -- Nick Roberts