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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca85d557480cf473 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-06 17:23:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!pcp01485549pcs.limstn01.de.comcast.NET!not-for-mail From: Ryan Tarpine Newsgroups: comp.lang.ada Subject: Re: Hiding a type Date: Sat, 06 Jul 2002 20:21:52 +0000 Message-ID: <3D275160.40907@hotmail.com> References: <3D27263F.7070101@hotmail.com> <7kJV8.2438$gy3.1099236449@newssvr12.news.prodigy.com> <3D2733F4.8010304@hotmail.com> NNTP-Posting-Host: pcp01485549pcs.limstn01.de.comcast.net (68.82.51.136) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1026001417 20039689 68.82.51.136 (16 [151722]) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020617 X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:26915 Date: 2002-07-06T20:21:52+00:00 List-Id: chris.danx wrote: > Follow the links on adapower and you'll get a link to Ada 95: the craft of > oo programming by John English. It's the best textbook, but nowadays you'll > be lucky to get it in a nice bound book, as it has gone out of print > (saturation apparently), but there is an online version so it's not gone > completely and it's free for everyone! > I always prefer to have a hardcopy for flipping through (although Mozilla's tabs let me flip between web pages easily, too!), and by a stroke of luck it seems that there are some used copies for sale off Amazon.com. I'll probably order a copy before the night's over :) >>... >>package Test is >> type Public_Name is limited private; >> function Initialize( File_Name : String ) return Public_Name; >> procedure Process( Input : Public_Name ); >>private >> type Private_Type is record ... end record; >> type Private_Type_Ptr is access all Private_Type; >> subtype Public_Name is Private_Type_Ptr; -- or what? >>end Test; >> >>... > > > Does that not do it? If it's right, it won't expose the private_type_ptr to > the world. The name public_name will hide private_type_ptr. > It looked correct when I wrote it, but that's not saying much since I only have a week of study under my belt :) GNAT tells me test.ads:2:10: missing full declaration for private type "Public_Name" test.ads:8:13: "Public_Name" conflicts with declaration at line 2 > >>To give more specific details as to what I'm doing, I'm trying to return >>a pointer to a node in a tree structure. There are several types of >>nodes and I'm concerned that in the future I will want to return a >>different type of node. I want to hide this from the client. > > > Doesn't the client need to know what type of node they're dealing with in > order to process it? > Not really, since I only want to return the root node of the tree. All public functions will only take whatever type the root node should be. As development continues, though, that type might change and another type might instead be used for the root. I only want to have to modify to the few public functions. This is, of course, only speculation in my mind and possibly could never happen... Thanks, Ryan