From: AdaMagica <christoph.grein@eurocopter.com>
Subject: Re: Enforcing initialization protocol for protected type
Date: Fri, 11 Sep 2009 08:25:56 -0700 (PDT)
Date: 2009-09-11T08:25:56-07:00 [thread overview]
Message-ID: <61284459-5a02-410a-8ffc-76ad4256f138@a7g2000yqo.googlegroups.com> (raw)
In-Reply-To: 7z37lspxbvu5.xk9ag8zcslry$.dlg@40tude.net
On 11 Sep., 11:03, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Thu, 10 Sep 2009 22:01:17 -0700 (PDT), AdaMagica wrote:
> > On 7 Sep., 22:19, Maciej Sobczak <see.my.homep...@gmail.com> 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.
next prev parent reply other threads:[~2009-09-11 15:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-07 15:15 Enforcing initialization protocol for protected type Maciej Sobczak
2009-09-07 17:01 ` Georg Bauhaus
2009-09-07 20:19 ` Maciej Sobczak
2009-09-10 17:07 ` Georg Bauhaus
2009-09-11 5:01 ` AdaMagica
2009-09-11 9:03 ` Dmitry A. Kazakov
2009-09-11 15:25 ` AdaMagica [this message]
2009-09-11 16:27 ` Dmitry A. Kazakov
2009-09-11 22:24 ` Randy Brukardt
2009-09-12 8:44 ` Dmitry A. Kazakov
2009-09-10 16:39 ` Per Sandberg
2009-09-14 21:15 ` Adam Beneschan
2009-09-15 0:27 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox