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-31 03:22:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Limited_Controlled types as 'out' arguments Date: Thu, 31 Jul 2003 12:26:56 +0200 Message-ID: <93nhiv8khhibv15shv21g2t3o179gf69kl@4ax.com> References: <73mfiv811s5187ci5cesv12dsbf88a0rvn@4ax.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1059646930 23867545 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:41067 Date: 2003-07-31T12:26:56+02:00 List-Id: On Wed, 30 Jul 2003 15:15:09 +0000 (UTC), Lutz Donnerhacke wrote: >* Dmitry A Kazakov wrote: >> On Wed, 30 Jul 2003 14:25:46 +0000 (UTC), Lutz Donnerhacke >>>* Dmitry A Kazakov wrote: >>>> On Wed, 30 Jul 2003 12:32:17 +0000 (UTC), Lutz Donnerhacke >>>>>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. >>>> >>>> You can in Ada 95. >>> >>>Oops. Why? This is a clear data flow error, which should be avoided. >> >> It is an interesting question. What could be alternatives >> >> 1. to leave "out" parameters uninitialized. This is bad. > >This is the most common implementation on most types. (most = unless you >define an Initialize procedure, default component data, or provide >initialization data) No they all are initialized, but probably with a garbage. (:-)) A really uninialized object is *(cast *) malloc (). Fortunately, we have no this evil in Ada. >> 2. to disallow reading from them, but then how to get discriminants? > >Discriminants of 'out' types have mode 'in'. Always. Not always: type A (I : Integer := 10) is null record; procedure Foo (X : out A) is begin X := (I => 5); -- Change the discriminant end Foo; >3) Finalize the current data of the 'limited out' parameter. > Adjust the assigned data of the 'unlimited out' paramter after return. It would be inconsistent. Adjust is called after a raw copy is made, your subprogram uses a valid type interface instead. And you better don't do it after Finalize [+ other destructors] were called. Consider a task object as a member of your limited type. What you actually describe is a copy constructor, not a subroutine. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de