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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3fc1c2283df835d5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-30 05:32:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Limited_Controlled types as 'out' arguments Date: Wed, 30 Jul 2003 12:32:17 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1059568337 12670 217.17.192.37 (30 Jul 2003 12:32:17 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Wed, 30 Jul 2003 12:32:17 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:40999 Date: 2003-07-30T12:32:17+00:00 List-Id: * Dmitry A Kazakov wrote: > On Wed, 30 Jul 2003 11:31:03 +0000 (UTC), Lutz Donnerhacke >> procedure Copy(to : out Test; from : Test); >> >>Clearly, the variable 0 and 3 are never finalized. How implement I this >>correctly (without refering to the rosen trick). > > 1. Why do you think that it is incorrect? Copy does not destruct the > target, so why should it call Finalize? In my implementation, the type Test contains an array_access, I have to deallocate, before assigning a new value. I can not deallocate this access variable, because the procedure Free (unchecked_deallocate) requires an 'in out' Parameter. But I only have an 'out' paramter. So I can't read it, before the first write. In short: The former contents (despite discriminates) of an 'out' parameter are not available inside the procedure. So the former contents are not finalizable inside this procedure. > procedure Copy (To : in out Test'Class; From : Test'Class) is > begin > Destruct (To); > Construct (To, From); > end Copy; Fine, but try this with the prototype: procedure Copy (To : out Test'Class; From : Test'Class); > Beware, true multiple dispatch is not supported in Ada. So if you want > to copy objects of different types you have to simulate MD. Wrong answer. Not every problem is MI related.