comp.lang.ada
 help / color / mirror / Atom feed
From: Magnus.Kempe@di.epfl.ch (Magnus Kempe)
Subject: Re: Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG)
Date: 29 Sep 1994 09:48:31 GMT
Date: 1994-09-29T09:48:31+00:00	[thread overview]
Message-ID: <1994Sep29.103358@di.epfl.ch> (raw)
In-Reply-To: 36bt0c$17oo@watnews1.watson.ibm.com


Norm's solution could be further improved as follows:

: One variation on this is to declare recursive types meant to serve as the
: parents of types Employee and Office, but to provide no operations for
: these recursive types.  Then, in child packages, declare Employee and
: Office themselves as derived types and declare primitive operations in
: those child packages: 

Since this couple of recursive types is strictly internal to the
abstraction "employee and his office", I recommend that they be
declared as abstract and hidden in the private part of the parent
package (Yes, this compiles with GNAT):

    package Company is
    private
      type Employee_Parent;
      type Employee_Pointer is access all Employee_Parent'Class;

      type Office_Parent;
      type Office_Pointer is access all Office_Parent'Class;


      type Employee_Parent is abstract tagged
        record
          Its_Occupied_Office : Office_Pointer;
        end record;

      type Office_Parent is abstract tagged
        record
          Its_Occupying_Employee : Employee_Pointer;
        end record;
    end Company;

The rest of Norm's solution doesn't change; the couple of abstractions
Employee and Office is declared in two child units of Company.  To the
client programmer, the encapsulation is strong but the relationship
between the two abstractions is quite apparent because they are exported
by the Company.* subsystem (a hierarchy of packages).

-- 
Magnus Kempe		"I know not what course others may take, but as for me,
Magnus.Kempe@di.epfl.ch  Give me Liberty... or give me Death!" -- Patrick Henry



  parent reply	other threads:[~1994-09-29  9:48 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 [this message]
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           ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Robert I. Eachus
1994-10-04  2:12             ` 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