From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1108a1,66253344eaef63db X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,66253344eaef63db X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,66253344eaef63db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-27 11:57:22 PST Newsgroups: comp.lang.ada,comp.object,comp.lang.c++ Path: bga.com!news.sprintlink.net!howland.reston.ans.net!spool.mu.edu!sgiblab!sgigate.sgi.com!enews.sgi.com!wdl1!dst17!mab From: mab@dst17.wdl.loral.com (Mark A Biggar) Subject: Re: Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Message-ID: <1994Sep27.184827.17813@wdl.loral.com> Keywords: Ada 9X, C++, object-oriented Sender: news@wdl.loral.com Organization: Loral Western Development Labs References: <1994Sep27.165203.9192@swlvx2.msd.ray.com> Date: Tue, 27 Sep 1994 18:48:27 GMT Xref: bga.com comp.lang.ada:6240 comp.object:6837 comp.lang.c++:30660 Date: 1994-09-27T18:48:27+00:00 List-Id: [Discussion of how to set up mutualy recursive tagged types] First of all you really only need to have a forward definition of one of the two types, lets choose office. So first define a abstract office type that doesn't knoe about employees: package Abs_Office is type Abstract_Office is abstract tagged null record; type Access_Office is access all Abstract_Office'class; end Abs_Office; Now we can define the employee type in terms of the above abstract type: with Abs_Office; use Abs_Office; package Emp is type Employee is tagged record Office: Access_Office; end record; type Employee_Access is access all Employee'class; end Emp; Now we can define the real office type: with Abs_Office; use Abs_Office; with Emp; use Emp; package Off is type Office is new Abstract_Office with record Employee: Employee_Access; end record; end Off; This of course ignores the private aspects of the C++ example given in the original article, but these are easly added using private types and/or private extensions in the above packages. Moral: if you need mutualy recursive tagged types with out breaking encapsulation, then use an abstract type for you forward reference. -- Mark Biggar mab@wdl.loral.com