comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: Child packages
Date: 20 Oct 1994 14:06:50 GMT
Date: 1994-10-20T14:06:50+00:00	[thread overview]
Message-ID: <385thq$kh6@watnews1.watson.ibm.com> (raw)
In-Reply-To: 38496c$1l1@gnat.cs.nyu.edu

In article <38496c$1l1@gnat.cs.nyu.edu>, dewar@cs.nyu.edu (Robert Dewar)
writes: 

|> Norman, there is still a big difference between modifying the text of a
|> package and adding a child, much to big for tantamout :-)
|>
|> The big difference is that if you modify the text of a package you can
|> blow up existing clients of that package in different programs.
|>
|> If you write a child, it is completely separate, and affects on programs
|> that use the child,
|>
|> so the level of access controls needed is quite different. a given program
|> may want to lock out any additional child units, and another program may
|> wish to allow them, but neither could permit the mucking with a shared
|> package's text.

This is true.  I should have said that adding a child is tantamount to
modifying a program's OWN COPY of a package.  (The point is that
encapsulation in a package provides no more protection against breaking
an abstraction by writing a child than it does against breaking an
abstraction by modifying the text of the package.  Access controls CAN
provide such protection, and I agree that child packages facilitate
access controls with a finer granularity.)

Even the comparison of a shared package with a program-specific child to
a program-specific copy of the package is not quite right, of course,
because a change to the shared copy is immediately reflected in each
program-specific copy.

Some changes to a shared parent may invalidate assumptions on which
children depended, thus breaking program-specific virtual copies of the
package.  However, others may not.  For example, if a bug is found in the
body of a subprogram provided by the parent, causing the subprogram to
violate its specifications in obscure cases, a fix to the parent package
immediately fixes the bug in all programs that use the package or its
children.  (If a program exploited the bug as a "feature", the bug fix
will break that program, but given my hypothesis that the bug violated
the subprogram's specifications, the fault in that case lies with the
program.)

The issue of maintaining a parent package shared by multiple programs
brings out a serious drawback of child units.

One of the breakthroughs provided by Ada 83 was the separation of a
module into distinct textual regions defining a module's interface (the
package visible part) and its implementation (the private part and body).
In languages not providing this clear textual distinction, it is common
to speak of "documented features" and "undocumented features" rather than
properties of the interface and properties of the implementation.  In Ada
83, the maintainer of a package always had complete freedom to change the
details of the implementation.  (Caveat unchecked-convertor.)

In Ada 94 there is a third category of features.  Between the interface
that may be exploited by clients and the implementation details that the
parent-package maintainer reserves the right to change, there is a set of
IMPLEMENTATION features that the package maintainer agrees to leave
unchanged, in the expectation that child units may exploit these
features.  (This distinction is analogous to the C++
public/protected/private trichotomy.)  Unfortunately, the distinction
between "private" implementation details (which even children should not
exploit) and "protected" implementation details (hidden from ordinary
clients but part of the interface as far as child units are concerned) is
not reflected in any way in the text of a parent package, except of
course in comments.  Thus we are back to distinguishing between
"documented features" of a package implementation and "undocumented
features".  (We would like to hope that the so-called "undocumented
features" are actually clearly DOCUMENTED, in comments, as not to be
relied on by child units!)

While child packages provide many more advantages than disadvantages, I
feel we have lost something important from Ada 83--a clearly marked,
compiler-recognized distinction between those aspects of a module that do
and do not form a part of its "contract".

--
Norman H. Cohen    ncohen@watson.ibm.com



  reply	other threads:[~1994-10-20 14:06 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-29 20:08 Is Ada the future? [was: Is C++ the future?] John DiCamillo
1994-09-30 13:45 ` David Weller
1994-10-01 21:40   ` John DiCamillo
1994-10-03  9:53     ` Robert I. Eachus
1994-10-03 20:41       ` John DiCamillo
1994-10-04  8:41         ` Robb Nebbe
     [not found]           ` <85C825A689A@annwfn.com>
1994-10-13 14:40             ` John Volan
1994-10-13 21:14               ` Matt Kennel
1994-10-14  0:37                 ` Robert Dewar
1994-10-14 10:16                 ` Robb Nebbe
1994-10-14 20:43                   ` Bob Duff
1994-10-13 22:01           ` Val Kartchner
1994-10-14  1:38             ` Robert Dewar
1994-10-14  9:31             ` Robb Nebbe
1994-10-14 16:16               ` Child packages [nn,pedo,incest,cons] Robert Firth
1994-10-14 17:13                 ` Robert I. Eachus
1994-10-17  8:18                   ` Robb Nebbe
1994-10-17 11:52                     ` Robert I. Eachus
1994-10-17 21:54                       ` Bob Duff
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 [this message]
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
1994-10-04 14:44         ` Is Ada the future? [was: Is C++ the future?] Robert Dewar
1994-10-04 15:53           ` Richard Kenner
     [not found] ` <36h4pc$9dd@starbase.neosoft.com>
1994-09-30 20:15   ` Benjamin Ketcham
1994-10-02 16:30   ` Robin Rowe
1994-10-02 18:00     ` David Weller
1994-10-03 15:55       ` Netspeak: What is "trolling"? Norman H. Cohen
1994-10-03 17:04         ` Kenneth Aubey 913-4481
1994-10-03 21:06       ` Is Ada the future? [was: Is C++ the future?] John DiCamillo
1994-10-04  0:29         ` David Weller
1994-10-04 17:42           ` John DiCamillo
1994-10-05  8:18             ` Magnus Kempe
1994-10-05 13:49             ` Tucker Taft
     [not found]         ` <36q7m5$4ef@starbase.neosoft.com>
1994-10-04 17:55           ` Robin Rowe
1994-10-04 22:42         ` Tucker Taft
1994-10-03  9:22     ` Andrew Lees
1994-10-03 21:31       ` John DiCamillo
1994-10-04 23:29         ` John DiCamillo
1994-10-05  3:52           ` Robin Rowe
1994-10-05 13:15             ` Robert Dewar
1994-10-05 13:54           ` David Weller
     [not found]             ` <36uhnl$4c1@gnat.cs.nyu.edu>
     [not found]               ` <37dp17$gp6@goanna.cs.rmit.oz.au>
1994-10-11 13:37                 ` Robert Dewar
1994-10-19 11:24               ` Stephen J Bevan
1994-10-19 15:51                 ` Robert Dewar
1994-10-25 12:21                   ` Stephen J Bevan
1994-10-05 17:08           ` Ted Dennison
     [not found]     ` <36msgr$qq2@starbase.neosoft.com>
1994-10-04  7:21       ` Ada compared to C++ Robin Rowe
1994-10-05  6:44         ` Bob Kitzberger
1994-10-05 12:02           ` Robert Dewar
1994-10-05 18:20           ` Bob Kitzberger
1994-10-05  8:44         ` Magnus Kempe
1994-10-05 19:55           ` David Weller
     [not found]   ` <1994Oct6.133002.1@rapnet.sanders.lockheed.com>
1994-10-16  3:30     ` Mark S. Hathaway
  -- strict thread matches above, loose matches on Subject: below --
1995-03-17  9:27 An observation of Ada (may offend) R.A.L Williams
1995-03-17 17:08 ` Norman H. Cohen
1995-03-23 16:38   ` Robert I. Eachus
1995-03-24 10:46     ` Peter Hermann
1995-03-27  9:59       ` Child packages Robb Nebbe
1995-03-28  1:11         ` Keith Thompson
1995-03-28 11:54           ` Keith Thompson
replies disabled

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