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,66f9ac28e8d63f60 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!a7g2000yqo.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Enforcing initialization protocol for protected type Date: Fri, 11 Sep 2009 08:25:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <61284459-5a02-410a-8ffc-76ad4256f138@a7g2000yqo.googlegroups.com> 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> <7z37lspxbvu5.xk9ag8zcslry$.dlg@40tude.net> NNTP-Posting-Host: 91.13.233.67 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1252682756 25749 127.0.0.1 (11 Sep 2009 15:25:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 11 Sep 2009 15:25:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a7g2000yqo.googlegroups.com; posting-host=91.13.233.67; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8291 Date: 2009-09-11T08:25:56-07:00 List-Id: On 11 Sep., 11:03, "Dmitry A. Kazakov" wrote: > 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. type Disc is ... type Rec (D: access Disc) is record ... Obj: Rec (new Disc); The discriminant (a coextension of the object) will be deallocated when Obj goes out of scope. subtype ConRec is Rec (new Disc); If I understand the RM correctly, the discriminant of objects of the constrained subtype is no coextensions; it will be deallocated when the subtype goes out of scope.