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!postnews.google.com!u7g2000yqm.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Passing the same actual as both in and out formal parameters? Date: Tue, 17 Nov 2009 03:26:29 -0800 (PST) Organization: http://groups.google.com Message-ID: <044632e0-e40c-4c47-ab56-189f4ae0c15b@u7g2000yqm.googlegroups.com> References: <1fbe454c-52b0-408b-9159-982fc019a53c@j19g2000yqk.googlegroups.com> <81utdh.otp.ln@hunter.axlog.fr> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1258457189 24227 127.0.0.1 (17 Nov 2009 11:26:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 17 Nov 2009 11:26:29 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u7g2000yqm.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8124 Date: 2009-11-17T03:26:29-08:00 List-Id: Jean-Pierre Rosen wrote on comp.lang.ada: > Ludovic Brenta a =E9crit : > > procedure P (A : in T; B : out T) is >> begin >> =A0 =A0B.L :=3D A.M; -- does this change A.L too? > Yes >> =A0 =A0B.M :=3D A.L; -- bug: A.L has been clobbered, now B.M =3D 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. My exampled was heavily simplified; the actual type has about a hundred components and the procedure P is a little more complex than swapping components :) But thanks for the responses, Niklas and Jean-Pierre. They confirm my suspicion. -- Ludovic Brenta.