comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Private Children
Date: 1999/06/22
Date: 1999-06-22T00:00:00+00:00	[thread overview]
Message-ID: <m3so7k3bsp.fsf@mheaney.ni.net> (raw)
In-Reply-To: dale-2206991424480001@192.168.0.2

On 22 Jun 1999 14:24, dale@cs.rmit.edu.au (Dale Stanbrough) wrote:

>          package P.Hidden_Level.Public_Level is
>            type some-type is tagged private;
>            -- some publicly exported services
>          private
>            ...
>          end P.Hidden_Level.Public_Level ;
>   
>          package body P.Hidden_Level.Public_Level is
>             -- implement exported services using the
>             -- private services in the hierarchy since
>             -- the body can see the private declarations
>             -- of parent its units.
>          end P.Hidden_Level.Public_Level;"
> 
> It's still a bit ordinary though. The services offered in the public
> level can't rely on abstractions advertised in the private section,
> which I see as the major failure of this model.

Yes, but you can make use of them in the private region.  For example,
this would be a handy way to implement the full view (declared in the
private region) of a private type (whose partial view is declared in the
public region).

As was suggested in earlier posts:

1) Declare the private stuff in the private region of the root package.
   This way you can get rid of the intermediate package:

  package P is 
  private
    <private stuff here>
  end P;

  package P.C is
    <public stuff>
  private
    <private stuff that depends on private stuff in P>
  end P.C;


2) Declare the private stuff in a child, declare grandchildren that use
   that private stuff, and then rename the grandchildren as children:

  package P is
  end P;

  package P.Private_Stuff is
  private
    <private stuff>
  end;

  package P.Private_Stuff.C is
    <public stuff>
  private
    <private stuff that depends on private stuff in P.Private_Stuff>
  end;

  package P.C renames P.Private_Stuff.C;


The idea behind both of these schemes is to hide that fact that private
stuff is being used at all.  You don't what to expose publicly (in the
form of an intermediate package in the hierarchy) what is essentially an
implementation issue.




  parent reply	other threads:[~1999-06-22  0:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-20  0:00 Private Children Matthew Heaney
1999-06-21  0:00 ` Ted Dennison
1999-06-21  0:00   ` Tucker Taft
1999-06-21  0:00     ` Matthew Heaney
1999-06-21  0:00     ` Matthew Heaney
1999-06-21  0:00       ` Tucker Taft
1999-06-22  0:00         ` Richard D Riehle
1999-06-22  0:00           ` Dale Stanbrough
1999-06-22  0:00             ` Richard D Riehle
1999-06-22  0:00             ` Matthew Heaney [this message]
1999-06-23  0:00               ` Dale Stanbrough
1999-06-23  0:00                 ` Matthew Heaney
1999-06-23  0:00                   ` Dale Stanbrough
1999-06-23  0:00                     ` Richard D Riehle
1999-06-23  0:00                       ` John Duncan
1999-06-23  0:00                       ` Vladimir Olensky
1999-06-23  0:00                         ` Richard D Riehle
1999-06-24  0:00                           ` Hyman Rosen
1999-06-24  0:00                             ` Richard D Riehle
1999-06-24  0:00                       ` Dale Stanbrough
1999-06-25  0:00   ` Robert Dewar
1999-06-21  0:00 ` Dale Stanbrough
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox