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-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!weretis.net!feeder2.news.weretis.net!news.tornevall.net!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Passing the same actual as both in and out formal parameters? Date: Tue, 17 Nov 2009 20:47:53 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <1fbe454c-52b0-408b-9159-982fc019a53c@j19g2000yqk.googlegroups.com> <7dde1f20-1b53-4ccf-8344-a60c9f500130@s21g2000prm.googlegroups.com> NNTP-Posting-Host: ad5de01f2a24f6548aaa67f26b5b5c64 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: a32704fdb432d6f6e28bc75924200240 X-Complaints-To: abuse@tornevall.net X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: X-Validate-Post: http://news.tornevall.net/validate.php?trace=a32704fdb432d6f6e28bc75924200240 X-SpeedUI: 1738 X-Complaints-Italiano: Parlo la lingua non � italiano User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) X-Posting-User: 9b22bfe2855937f9b3faeec7cfc91295 Xref: g2news1.google.com comp.lang.ada:8137 Date: 2009-11-17T20:47:53-07:00 List-Id: Adam Beneschan wrote: > On Nov 17, 4:11 pm, "Jeffrey R. Carter" > wrote: >> >> pragma Assert (A'access /= B'access); > > First of all, for this to work in the general case, that would need a > major change in language semantics, since you need an access type in > order for 'Access to be allowed. The only way this would be legal is > if there happened to be exactly one "=" operator directly visible with > operands of some named access-to-T type. (Also, if "=" were > overridden with a user-defined operator that did something unexpected, > it would fail, but nobody would do that.) OK. Since this in the body of the operation, it seems doable: procedure P (A : in T; B : out T) is type T_Ptr is access T; A_Ptr : constant T_Ptr := A'access; B_Ptr : constant T_Ptr := B'access; pragma Assert (A_Ptr /= B_Ptr); So you're guaranteed that "=" for T_Ptr is used, and you know it hasn't been overridden. What about 'Address? > Second, it only catches the case where the operands are of the same > type; it won't catch other overlaps such as > > P2 (A => Object, B => Object.Component); Sure, it's not a general solution; I doubt if there could be one. But it does seem to serve for the OP's case. -- Jeff Carter "You cheesy lot of second-hand electric donkey-bottom biters." Monty Python & the Holy Grail 14