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!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!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> In-Reply-To: <1104293158.276241.42640@f14g2000cwb.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Wed, 29 Dec 2004 04:49:10 GMT NNTP-Posting-Host: 4.240.189.163 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1104295750 4.240.189.163 (Tue, 28 Dec 2004 20:49:10 PST) NNTP-Posting-Date: Tue, 28 Dec 2004 20:49:10 PST Xref: g2news1.google.com comp.lang.ada:7280 Date: 2004-12-29T04:49:10+00:00 List-Id: danmcleran@hotmail.com wrote: > Is there any way to hide implementation detail from child packages? An > example, say I have a parent package like this: > > package Some_Package is > type Secret_Type is private; > private > type Secret_Type is record > Secret_Value : Integer := 0; > end record; > end Some_Package; > > I don't want any other component to be able to manipulate the > Secret_Value record component, not even a child package of > Some_Package. If you don't need to make the type visible at all, you can simply declare it in the package body. Items in package bodies are hidden from all other scopes. If you want the type to be visible, but its implementation to be hidden, you can use a pointer: package P is type Something is [limited] private; -- operations on Something private -- P type Implementation; type Something is access [all] Implementation; end P; The full view of Implementation must then be given in the body of P. If you do this, you're responsible for the memory management of Something. This is usually easier if you make Something limited, since the client cannot then make copies of the access values, eliminating opportunities for dangling references. -- Jeff Carter "Beyond 100,000 lines of code you should probably be coding in Ada." P. J. Plauger 26