comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Extending a type and Finalization
Date: Thu, 4 Jun 2009 14:18:41 -0700 (PDT)
Date: 2009-06-04T14:18:41-07:00	[thread overview]
Message-ID: <e805e0d7-bc8a-4061-8692-400aa55e5bfa@t10g2000vbg.googlegroups.com> (raw)
In-Reply-To: 1weng8cyxd5bf$.19oxow5s49g48$.dlg@40tude.net

On Jun 4, 1:06 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Thu, 4 Jun 2009 12:33:04 -0700 (PDT), Adam Beneschan wrote:
> > In addition to making an individual component a Limited_Controlled
> > type, you can use trickery using access discriminants to allow the
> > Initialize and Finalize routines to access the entire record.
> > Assuming P.T is limited, you can define something like:
>
> >    type Control_Type (Ref : access P.T'Class) is new
> >        Ada.Finalization.Limited_Controlled with null record;
>
> >    overriding procedure Initialize (Obj : in out Control_Type);
> >    overriding procedure Finalize   (Obj : in out Control_Type);
>
> > And then when defining TT:
>
> >    type TT is new P.T with record
> >       Control : Control_Type (TT'Access);
> >       ...
> >    end record;
>
> > Then when you declare an object of type TT, Initialize will be called
> > on the Control component, and the access discriminant Ref will give
> > you access to the entire record inside the Initialize and Finalize
> > routines.
>
> > (This idea isn't mine.  It might be Matthew Heaney's, but I'm not
> > sure.  The Control_Type declaration was adapted from a "shapes"
> > demonstration program, but I'm not sure where it came from.)
>
> I am not sure if this pattern is safe. What gives a guaranty that other
> components of TT are initialized before the Initialize gets called on
> Control and finalized after the Finalize gets called?

RM 7.6(12)

                            -- Adam




  reply	other threads:[~2009-06-04 21:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-04 17:45 Extending a type and Finalization pascal.malaise
2009-06-04 18:00 ` Hibou57 (Yannick Duchêne)
2009-06-04 19:33   ` Adam Beneschan
2009-06-04 20:06     ` Dmitry A. Kazakov
2009-06-04 21:18       ` Adam Beneschan [this message]
2009-06-05  9:11         ` Dmitry A. Kazakov
2009-06-05 14:48           ` Adam Beneschan
2009-06-05 17:15             ` Dmitry A. Kazakov
2009-06-05 11:29     ` malaise
2009-06-05 12:21       ` Ludovic Brenta
2009-06-05 13:02         ` malaise
2009-06-05 13:14           ` Ludovic Brenta
2009-06-05 13:32             ` malaise
2009-06-15  6:30 ` AdaMagica
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox