From: Ryan Tarpine <rtarpine@hotmail.com>
Subject: Re: Hiding a type
Date: Sat, 06 Jul 2002 18:16:20 +0000
Date: 2002-07-06T18:16:20+00:00 [thread overview]
Message-ID: <3D2733F4.8010304@hotmail.com> (raw)
In-Reply-To: 7kJV8.2438$gy3.1099236449@newssvr12.news.prodigy.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.
>>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
next prev parent reply other threads:[~2002-07-06 18:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-06 17:17 Hiding a type Ryan Tarpine
2002-07-06 21:30 ` Pat Rogers
2002-07-06 18:16 ` Ryan Tarpine [this message]
2002-07-06 22:49 ` sk
2002-07-06 22:52 ` Frank J. Lhota
2002-07-06 20:38 ` Ryan Tarpine
2002-07-07 10:31 ` Frank J. Lhota
2002-07-07 11:20 ` Simon Wright
2002-07-07 13:58 ` Frank J. Lhota
2002-07-07 22:24 ` Ryan Tarpine
2002-07-07 17:15 ` Jeffrey Carter
2002-07-07 17:58 ` Simon Wright
2002-07-06 23:10 ` chris.danx
2002-07-06 20:21 ` Ryan Tarpine
2002-07-07 1:58 ` Jeffrey Carter
2002-07-08 7:20 ` Preben Randhol
2002-07-06 23:12 ` chris.danx
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox