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 15:18:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.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 18:16:20 +0000 Message-ID: <3D2733F4.8010304@hotmail.com> References: <3D27263F.7070101@hotmail.com> <7kJV8.2438$gy3.1099236449@newssvr12.news.prodigy.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 1025993884 20452334 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:26908 Date: 2002-07-06T18:16:20+00:00 List-Id: 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. >>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. 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. Thank you again, Ryan