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: a07f3367d7,9cccd7364739aea1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Passing the same actual as both in and out formal parameters? Date: Tue, 17 Nov 2009 11:31:02 +0100 Organization: Adalog Message-ID: <81utdh.otp.ln@hunter.axlog.fr> References: <1fbe454c-52b0-408b-9159-982fc019a53c@j19g2000yqk.googlegroups.com> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1258456546 14961 195.25.228.57 (17 Nov 2009 11:15:46 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 17 Nov 2009 11:15:46 +0000 (UTC) User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) In-Reply-To: <1fbe454c-52b0-408b-9159-982fc019a53c@j19g2000yqk.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:8123 Date: 2009-11-17T11:31:02+01:00 List-Id: Ludovic Brenta a �crit : > procedure P (A : in T; B : out T) is > begin > B.L := A.M; -- does this change A.L too? Yes > B.M := A.L; -- bug: A.L has been clobbered, now B.M = B.L? > end P; > > My concern stems from the fact that T is tagged (I cannot change > that), so Object is passed by reference as both A and B. > > Am I right to be concerned? > Depend on what your concern is ;-) The semantic is well defined: tagged types are by-reference type. If you want to swap two fields of different parameters of the same type, use a local variable. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr