comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG)
Date: 3 Oct 94 12:14:10
Date: 1994-10-03T12:14:10+00:00	[thread overview]
Message-ID: <EACHUS.94Oct3121410@spectre.mitre.org> (raw)
In-Reply-To: jgv@swl.msd.ray.com's message of Sun, 2 Oct 1994 16:41:05 GMT

In article <1994Oct2.164105.13127@swlvx2.msd.ray.com> jgv@swl.msd.ray.com (John Volan) writes:

   > adam@irvine.com (Adam Beneschan) writes:

   >> I'd like to chime in and say I'm not satisfied either.... 

   > I fear there may be many of us out there.

   > That's my fear as well.  That's why I've been trying very hard to
   > find an Ada9X solution.  Eiffel can do decoupled mutual recursion
   > standing on its head.  Smalltalk virtually swims in a sea of
   > decoupled mutual recursion (trivial in a typeless language).  I
   > suspect C++ can actually manage it as well.  (Can any C++ folks
   > confirm this?  Realize what I mean: Can you forward-declare a
   > class and then *not* complete its declaration in the same header
   > file, and yet complete the declaration of a client class?  Or do
   > you *have* to declare both classes in the same header file?)

   Stated this way, you are trying to solve a different problem than
the original one.  This one has a very simple solution: child units.
This eliminates the "necessity" for mutual recursion in the visible
package specifications.

   However, there are limitations to this approach.  (Let me do a bit
of a sketch here:

   package Employees is
     type Employee is tagged private;
     ...
   end Employees;

   package Offices is
     type Office is tagged private;
     ...
   end Offices;

   with Offices; use Offices;
   function Employees.Assigned_Office(E: in Employee) return Office;

   with Employees; use Employees;
   function Offices.Occupant(O: in Office) return Employee;

   As sketched, this provides a clean, clear interface.  However there
are two problems.  First, there is going to have to be some
abstraction breaking to implement the bodies of these units.  It can
be done in a type safe manner, with private child units, and there are
other possibilities.

   Second, these functions are not inheritable, so you might want:

   with Offices; use Offices;
   function Employees.Assigned_Office(E: in Employee'CLASS)
        return Office'CLASS;

   with Employees; use Employees;
   function Offices.Occupant(O: in Office'CLASS) return Employee'CLASS;

   instead of the versions above.  Since such subprograms would have
to deal with all of the (possibly) many subclasses to employees or
offices, this approach can result in unmaintainable code. However for
small projects, or for attributes which are orthogonal to the rest of
the abstraction, this approach works just fine.

    If any extension to the current draft standard is required in this
area--and I don't think one is--it would be to change 3.2.3(6) to make
child units eligible as primitive operations, probably under the
influence of a pragma.   I certainly don't recommend such a change to
the standard--it would open up all sorts of holes--but that should
prevent someone from experimenting with such a pragma.

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...



  parent reply	other threads:[~1994-10-03 12:14 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-27 16:52 Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) John Volan
1994-09-27 18:48 ` Mark A Biggar
1994-09-29  1:46   ` John Volan
1994-09-29 13:57     ` Tucker Taft
1994-09-29 17:20       ` Bjarne Stroustrup <9758-26353> 0112760
1994-09-30  1:38         ` Tucker Taft
1994-09-30 12:33           ` Bjarne Stroustrup <9758-26353> 0112760
1994-09-29 18:37       ` John Volan
1994-09-29 19:34         ` David Weller
1994-09-30 22:13           ` John Volan
1994-10-02  3:31             ` Andrew Lees
1994-09-30  1:47         ` Tucker Taft
1994-09-30 13:30           ` John Volan
1994-09-29 18:10     ` R. William Beckwith
1994-10-03  0:33     ` Cyrille Comar
1994-09-28 14:01 ` Norman H. Cohen
1994-09-29  2:12   ` John Volan
1994-09-29 14:01     ` Tucker Taft
1994-09-29 18:37     ` Norman H. Cohen
1994-09-29  9:48   ` Magnus Kempe
1994-09-29 13:10     ` Magnus Kempe
1994-09-29 18:05       ` Tucker Taft
1994-09-30 10:20         ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? Magnus Kempe
1994-09-30 13:22           ` Tucker Taft
1994-10-01  1:24       ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Adam Beneschan
1994-10-01 12:01         ` Magnus Kempe
1994-10-01 18:43         ` Mark A Biggar
1994-10-02 16:41         ` John Volan
1994-10-02 23:33           ` Matt Kennel
1994-10-03  8:07           ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? Magnus Kempe
1994-10-03 12:14           ` Robert I. Eachus [this message]
1994-10-04  2:12             ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) R. William Beckwith
1994-10-04 16:00             ` John Volan
1994-10-05 11:42               ` Robert I. Eachus
1994-10-05 21:09               ` Matt Kennel
1994-10-03 20:29           ` Harry Koehnemann
1994-09-29 13:35     ` John Volan
1994-09-30 20:27       ` Norman H. Cohen
1994-10-01  1:47         ` John Volan
1994-10-01 20:44           ` Tucker Taft
1994-10-03 11:29           ` Robert I. Eachus
1994-09-30 22:46       ` Matt Kennel
1994-10-01  2:11         ` John Volan
replies disabled

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