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 08:15:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!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 15:15:09 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <73mfiv811s5187ci5cesv12dsbf88a0rvn@4ax.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1059578109 20386 217.17.192.37 (30 Jul 2003 15:15:09 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Wed, 30 Jul 2003 15:15:09 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:41018 Date: 2003-07-30T15:15:09+00:00 List-Id: * 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) > 2. to disallow reading from them, but then how to get discriminants? Discriminants of 'out' types have mode 'in'. Always. > 2.a. to disallow reading before first write except for discriminants, > constraints and type tag. Discriminants, ... can't be written on 'out' types. > 2.b. return statement for "out" > > procedure Foo (X : out String; Y : Some'Class) is > begin > return > ( X => "Any text", > Y => Create_Some > ); > end Foo; No! 3) Finalize the current data of the 'limited out' parameter. Adjust the assigned data of the 'unlimited out' paramter after return.