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,ca85d557480cf473 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-06 16:11:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.stueberl.de!newspeer1-gui.server.ntli.net!ntli.net!news11-gui.server.ntli.net.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <3D27263F.7070101@hotmail.com> <7kJV8.2438$gy3.1099236449@newssvr12.news.prodigy.com> <3D2733F4.8010304@hotmail.com> Subject: Re: Hiding a type X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Sun, 7 Jul 2002 00:10:45 +0100 NNTP-Posting-Host: 80.5.140.234 X-Complaints-To: abuse@ntlworld.com X-Trace: news11-gui.server.ntli.net 1025997077 80.5.140.234 (Sun, 07 Jul 2002 00:11:17 BST) NNTP-Posting-Date: Sun, 07 Jul 2002 00:11:17 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:26911 Date: 2002-07-07T00:10:45+01:00 List-Id: "Ryan Tarpine" wrote in message news:3D2733F4.8010304@hotmail.com... > Pat Rogers wrote: > > > Do check out a textbook from the library -- it is worth the time -- or > > take one of the on-line tutorials. See www.adapower.com. > > I hope to get a textbook soon. I'll have to buy one, as my local > library is quite small. I've read most of Ada Distilled and use it as a > quick reference, and I don't find the reference manual too difficult to > look through because I've used much more cumbersome languages before > **ahem**c++**cough**. The Lovelace tutorial is also wonderful. 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 want to write functions that will return something of type Hide in a > >>way so clients can't do anything except pass it to other functions. I > >>also don't want them to know if I change how I implement it. (In my > >>real program, I'm trying to hide that Foo returns an access type.) > >>Please tell how I should actually do this > > > > > > package Opaque is > > type Hidden is limited private; > > -- declare the operations here that you want to export to clients > > private > > type Hidden is access all Integer; > > end Opaque; > > I'm sorry but I didn't make it clear enough. It's more like this: > > 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; > > I don't want to expose the name Private_Type_Ptr because I know that it > might change in the future. I know it sounds silly so it's probably > just poor planning on my part. 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. > 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?