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 From: "zork" Newsgroups: comp.lang.ada References: <4104d5de@dnews.tpgi.com.au> Subject: Re: "out" and "in out" Date: Thu, 29 Jul 2004 00:07:48 +1000 Organization: - X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 220.244.246.44 X-Original-NNTP-Posting-Host: 220.244.246.44 Message-ID: <4107b35c@dnews.tpgi.com.au> X-Trace: dnews.tpgi.com.au!tpg.com.au 1091023708 220.244.246.44 (29 Jul 2004 00:08:28 +1000) Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!newsfeed.freenet.de!nntp.gblx.net!nntp3.phx1!dnews.tpgi.com.au!tpg.com.au!not-for-mail Xref: g2news1.google.com comp.lang.ada:2441 Date: 2004-07-29T00:07:48+10:00 List-Id: Thanks for the response everyone. I need to be careful in my implementation. Some things are obviously not obvious :) cheers zork "Nick Roberts" wrote in message news:opsbq1zzd0p4pfvb@bram-2... > 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