comp.lang.ada
 help / color / mirror / Atom feed
From: Ryan Tarpine <rtarpine@hotmail.com>
Subject: Re: Hiding a type
Date: Sat, 06 Jul 2002 20:21:52 +0000
Date: 2002-07-06T20:21:52+00:00	[thread overview]
Message-ID: <3D275160.40907@hotmail.com> (raw)
In-Reply-To: pOKV8.15189$xf3.2097028@news11-gui.server.ntli.net

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




  reply	other threads:[~2002-07-06 20:21 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
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 [this message]
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