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: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newspump.monmouth.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: memory management in Ada: tedious without GC? Date: Fri, 23 May 2008 19:03:28 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> <9f2c2db4-d6c1-4cdf-884c-5cbc26ac7701@d1g2000hsg.googlegroups.com> <5184e351-1971-484c-a74b-16156544ec00@x41g2000hsb.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1211583809 21325 192.74.137.71 (23 May 2008 23:03:29 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 23 May 2008 23:03:29 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:FAv6rQNCk/03A8Irp4JkHUDZgMA= Xref: g2news1.google.com comp.lang.ada:307 Date: 2008-05-23T19:03:28-04:00 List-Id: Matthew Heaney writes: > On May 19, 4:35�am, Maciej Sobczak wrote: >> >> How would you use this strategy to make a controlled stream (derived >> from Root_Stream_Type)? > > package P is > type T is new Root_Stream_Type with private; > procedure Op (O : not null access T); -- or whatever > private > type Control_Type (O : not null access T) is > new Limited_Controlled with null record; > > -- override Init and Final as req'd > > type T is new Root_Stream_Type with record > Control : Control_Type (T'Access); > -- other components as req'd > end record; > end P; Yes, but this idiom is needed only when the Finalize of the derived type needs to do something with the components of the parent type. I think that's unusual. The more common thing is to extend a type with some controlled components -- each component cleans up itself. So you don't normally need that pointer-to-containing-object. By the way, O is a horrible name! - Bob