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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,66f9ac28e8d63f60 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Enforcing initialization protocol for protected type Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1fcccc80-0142-4f07-8852-8d151ea96ee2@c37g2000yqi.googlegroups.com> <4aa53c59$0$30237$9b4e6d93@newsspool1.arcor-online.net> <73fb1051-edf9-43f8-be50-5a2faa866040@s31g2000yqs.googlegroups.com> Date: Fri, 11 Sep 2009 11:03:41 +0200 Message-ID: <7z37lspxbvu5.xk9ag8zcslry$.dlg@40tude.net> NNTP-Posting-Date: 11 Sep 2009 11:03:41 CEST NNTP-Posting-Host: dfa62679.newsspool3.arcor-online.net X-Trace: DXC=A<_D4j`<9TO^B]`=U:WelBMcF=Q^Z^V3H4Fo<]lROoRA^YC2XCjHcbIS7H=QbWHU8FDNcfSJ;bb[EFCTGGVUmh?DLK[5LiR>kgBdSNG9PAi\\B X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8286 Date: 2009-09-11T11:03:41+02:00 List-Id: On Thu, 10 Sep 2009 22:01:17 -0700 (PDT), AdaMagica wrote: > On 7 Sep., 22:19, Maciej Sobczak wrote: >> This, however, opens another question: controlled finalization of >> protected types to release the state object, if it was allocated >> dynamically. Oops. > > Use an access discriminant of an anonymous type and you will get a > coextension that is reclaimed automatically when the object goes out > of scope, see RM 3.10(14.3/2,14.4/2) [or in the newest draft of the > Amendment 2, (14.1/3,14.4/3), which is a bit clearer]. > > See also RM 3.7(1.c/2..1.e/2). Hmm, what do you mean by that? When the discriminant's type is an anonymous access it is still declared at the declaration point of the type. It is not the declaration point of an object. So if the discriminant is obtained by the allocator new it will not be destroyed when the object leaves the scope. It will when the type does. If these scopes are different, the compiler will complain that the type in the allocator has a deeper level. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de