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,8eff44ec1bcf8433 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-18 08:41:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!opentransit.net!proxad.net!news-hub.cableinet.net!blueyonder!btnet-peer!btnet!peer.news.eu-x.com!server2.netnews.ja.net!newshost.central.susx.ac.uk!news.bton.ac.uk!not-for-mail From: John English Newsgroups: comp.lang.ada Subject: Re: Container reqs Date: Thu, 18 Oct 2001 16:26:48 +0100 Organization: University of Brighton Message-ID: <3BCEF4B8.B1AC6965@brighton.ac.uk> References: <9qctpn$lil$1@news.huji.ac.il> <3BCA86C7.BB252751@acm.org> <%jYy7.31350$ev2.37672@www.newsranger.com> <3BCD7C50.647ADBD0@brighton.ac.uk> NNTP-Posting-Host: pc2je.it.bton.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: saturn.bton.ac.uk 1003419195 24114 193.62.183.154 (18 Oct 2001 15:33:15 GMT) X-Complaints-To: news@bton.ac.uk NNTP-Posting-Date: 18 Oct 2001 15:33:15 GMT X-Mailer: Mozilla 4.7 [en-gb] (Win95; U) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:14893 Date: 2001-10-18T15:33:15+00:00 List-Id: Ted Dennison wrote: > > In article <3BCD7C50.647ADBD0@brighton.ac.uk>, John English says... > > > >of controlled). And you can use tricks to get around the library-level > >problem, e.g. have a library-level parent package which defines a private > >controlled type and generic children which make use of those controlled > >objects as components in other composite types... > > This sounds a bit like the trick Dr. Dewar keeps referring to. I know this is > off the thread's topic, but could you give a specific example of how this works? I do something like this in JEWL. There's a reference-counted tagged type in package JEWL (non-generic parent): type Reference_Counted_Type is tagged limited record Count : Natural := 1; end record; procedure Cleanup (Object : in out Reference_Counted_Type); type Reference_Counted_Ptr is access all Reference_Counted_Type'Class; type Controlled_Type is new Ada.Finalization.Controlled with record Pointer : Reference_Counted_Ptr; end record; procedure Finalize (Object : in out Controlled_Type); procedure Adjust (Object : in out Controlled_Type); and then JEWL.Windows (which is generic) uses this Controlled_Type as a component (actually *the* component) in all the window types, so that all windows are implemented as pointers to reference-counted types. The actual object that a particular type of window points to is one of a variety of possible derivations which are defined in a private child and produced by constructor (factory) functions. > I could never see how one could use a controlled-type record field to manage > anything in its parent object, about which it theoreticly knows nothing. You can also use access discriminants to get at the containing record, but I didn't need to in this case... This is presumably what you're after? There's a description of the technique near the end of section 4.6 in part 2 of the Rationale: http://burks.bton.ac.uk/burks/language/ada/rat95/rat2_4.htm#6 ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.comp.it.bton.ac.uk/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------