comp.lang.ada
 help / color / mirror / Atom feed
From: kst@thomsoft.com (Keith Thompson)
Subject: Re: Child packages
Date: Tue, 28 Mar 1995 01:11:12 GMT
Date: 1995-03-28T01:11:12+00:00	[thread overview]
Message-ID: <D64Lyo.ML9@thomsoft.com> (raw)
In-Reply-To: 1995Mar27.115304@di.epfl.ch

In <1995Mar27.115304@di.epfl.ch> Robb.Nebbe@di.epfl.ch (Robb Nebbe) writes:
> I don't see how something like who can add a child package is fundamentally
> any different that who can modify a package. In my opinion a pragma
> to deal with this situation would do more harm than good.

For a set of compilation units provided by a commercial vendor, the full
specification and body sources may not be available, making modification
difficult or impossible.  Adding a child unit is relatively easy.
(Some would argue that all the sources should always be made available,
but I don't think that assumption should be built into the language;
realistically, sources *won't* always be available.)

One advantage of such a pragma is that it gives users an ability that
currently only implementations have.  I think this has always been a
design goal of Ada.  (For example, unlike their equivalents in many
other languages, Character is an ordinary enumeration type and Text_IO
is an ordinary library package; users can write their own replacements
for them if desired.)

RM95-A(4) says

    The implementation may restrict the replacement of language-defined
    compilation units.  The implementation may restrict children of
    language-defined library units (other than Standard).

In a small way, this gives the language-defined units a special status.
An implementer of a set of non-language-defined units can have the
same reasons to impose such restrictions that an implementer of the
language-defined units might have.

On the other hand, the only real extra power a child unit gives you
is visibility to the parent's private part.  You can restrict this by
hiding implementation details within a *nested* private part (this is
based on something Tucker Taft briefly mentioned a while ago).

	package Black_Box is
	   type Hidden is private;
	private
	   package Inner_Black_Box is
	      type Inner_Hidden is private;
	   private
	      type Inner_Hidden is (Why_Are_You_Looking_At_Me);
	   end Inner_Black_Box;
	   type Hidden is new Inner_Black_Box.Inner_Hidden;
	end Black_Box;

Now even a private child of package Black_Box can't access the full
declaration of type Hidden.  Since child units can only be declared at
the library level, you can't declare a child of Inner_Black_Box, so its
private part is truly private.

Admittedly, this doesn't let you selectively export private types to
some units but not to others.

-- 
Keith Thompson (The_Other_Keith)  kst@thomsoft.com (kst@alsys.com still works)
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
That's Keith Thompson *with* a 'p', Thomson Software Products *without* a 'p'.



  reply	other threads:[~1995-03-28  1:11 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-17  9:27 An observation of Ada (may offend) R.A.L Williams
1995-03-17 15:23 ` Robb Nebbe
1995-03-17 17:08 ` Norman H. Cohen
1995-03-20  3:23   ` S. Tucker Taft
1995-03-20 10:13   ` Robb Nebbe
1995-03-21 21:05     ` Robert Dewar
1995-03-20 16:15   ` Robert I. Eachus
1995-03-21 19:47     ` Norman H. Cohen
1995-03-22  1:28       ` David Weller
1995-03-23  5:47       ` Robert Dewar
1995-03-23 16:38         ` Robert I. Eachus
1995-03-24 10:46           ` Peter Hermann
1995-03-24 16:52             ` David Weller
1995-03-26  4:03               ` Robert Dewar
1995-03-24 21:33             ` Tucker Taft
1995-03-27  9:59             ` Child packages Robb Nebbe
1995-03-28  1:11               ` Keith Thompson [this message]
1995-03-28 11:54                 ` Keith Thompson
1995-03-27 18:58             ` An observation of Ada (may offend) Mark A Biggar
1995-03-24 19:45           ` Garlington KE
1995-03-27 19:58             ` Robert I. Eachus
1995-03-28 16:29               ` Garlington KE
1995-03-28 19:30                 ` Robert I. Eachus
1995-03-28 22:37                   ` Garlington KE
1995-03-29  8:31                   ` Robb Nebbe
1995-03-25 17:58           ` Robert Dewar
1995-03-26  6:20             ` R_Tim_Coslet
1995-03-27 20:38               ` Robert I. Eachus
1995-03-26  3:50           ` celier
     [not found]           ` <3l1lkq$pm6@gnat.csn <3l2o9a$3a1@infomatch.com>
1995-03-27 23:16             ` Robert Dewar
1995-03-23 18:05       ` John DiCamillo
1995-03-17 23:01 ` Larry Kilgallen, LJK Software
1995-03-18 12:41 ` Tucker Taft
1995-03-22 16:50 ` Renaud HEBERT
1995-03-23 23:23   ` John Volan
1995-03-24  0:38   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1994-10-04  8:41 Is Ada the future? [was: Is C++ the future?] Robb Nebbe
1994-10-13 22:01 ` Val Kartchner
1994-10-17 11:52   ` Child packages [nn,pedo,incest,cons] Robert I. Eachus
1994-10-18 10:30     ` Child packages Robb Nebbe
1994-10-18  9:37       ` Robert I. Eachus
1994-10-18 19:09         ` Robert Dewar
1994-10-19 11:03           ` Robert I. Eachus
1994-10-19 16:24             ` Norman H. Cohen
1994-10-19 23:13               ` Robert Dewar
1994-10-20 14:06                 ` Norman H. Cohen
1994-10-20 11:09                   ` Robert I. Eachus
1994-10-20 19:02                     ` Benjamin Ketcham
1994-10-20 17:08                       ` Robert I. Eachus
1994-10-20 16:37                   ` Bob Duff
1994-10-20 16:40                     ` Bob Duff
1994-10-21 14:02                     ` Mark Biggar, 5172
1994-10-21  8:48                   ` Robb Nebbe
1994-10-19 18:54             ` Robert Dewar
1994-10-20  0:27             ` Matt Kennel
1994-10-20  8:21               ` Magnus Kempe
1994-10-20 13:52               ` John Volan
1994-10-19 16:19           ` Norman H. Cohen
replies disabled

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