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,93d7def3eeefbc26 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Private area and child packages References: <1104293158.276241.42640@f14g2000cwb.googlegroups.com> <1104420708.559607.11230@z14g2000cwz.googlegroups.com> In-Reply-To: <1104420708.559607.11230@z14g2000cwz.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 30 Dec 2004 18:14:06 GMT NNTP-Posting-Host: 4.254.202.105 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1104430446 4.254.202.105 (Thu, 30 Dec 2004 10:14:06 PST) NNTP-Posting-Date: Thu, 30 Dec 2004 10:14:06 PST Xref: g2news1.google.com comp.lang.ada:7332 Date: 2004-12-30T18:14:06+00:00 List-Id: danmcleran@hotmail.com wrote: > What about using Ada's Limited_Controlled type? Then, since no copies > could be made, I could do something like this: > > with Ada.Finalization; > > package Some_Package is > type Secret_Type is tagged limited private; > private > type Implementation_Type; > type Implementation_Access_Type is access Implementation_Type; > type Secret_Type is new Ada.Finalization.Limited_Controlled with > record > Implementation_Access : Implementation_Access_Type := null; > end record; > end Some_Package; Don't forget to override Finalize. This doesn't really do what you want, since a child can see and copy the access component: package body Some_Package.Child is A : Implementation_Access_Type procedure Op (L : Secret_Type) is -- null; begin -- Op A := L.Implementation_Access; end Op; ... end Some_Package.Child; It's possible for the actual of L to go out of scope and be finalized, deallocating L.Implementation_Access, while A is still around, a dangling reference. -- Jeff Carter "Now look, Col. Batguano, if that really is your name." Dr. Strangelove 31