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: 103376,66253344eaef63db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-04 03:12:34 PST Newsgroups: comp.lang.ada,comp.object Path: bga.com!news.sprintlink.net!howland.reston.ans.net!cs.utexas.edu!uunet!ois!beckwb From: beckwb@ois.com (R. William Beckwith) Subject: Re: Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Message-ID: Followup-To: comp.lang.ada,comp.object Organization: Objective Interface Systems, Inc. X-Newsreader: TIN version 1.2 PL2 References: <1994Sep27.165203.9192@swlvx2.msd.ray.com> Date: Tue, 4 Oct 1994 02:12:16 GMT Xref: bga.com comp.lang.ada:6435 comp.object:7033 Date: 1994-10-04T02:12:16+00:00 List-Id: O.K., I guess I've been watching on the side lines too long :-). I addressed the issue of mutual recursion (I called it the `withing' problem) with Tuck early in our efforts to map CORBA IDL to Ada 9X. Since then, we have solved the problem. I have said to several people that you may want to use a CORBA IDL to Ada translator even for non-distributed systems. Now is my chance to put up or shut up. In C++ you can have mutual recursion: // file chicken.h #ifndef CHICKEN #define CHICKEN class Chicken; #include "egg.h" class Chicken { public: Egg lay(); }; #endif // file egg.h #ifndef EGG #define EGG class Egg; #include "chicken.h" class Egg { public: Chicken hatch(); }; #endif In CORBA IDL you can have mutual recursion: // file chicken.idl #ifndef CHICKEN #define CHICKEN interface Chicken; #include interface Chicken { Egg lay(); }; #endif // file egg.idl #ifndef EGG #define EGG interface Egg; #include interface Egg { Chicken hatch(); }; #endif In Ada 9X you can have mutual recursion: (result of IDL to Ada 9X translator with simplifications) with Ada.Finalization; package Corba is type Object is tagged ... type Ref is tagged ... end Corba; ------------------------------------------------- with Corba; package chicken_file is type Chicken_Ref is new Corba.Ref with null record; end chicken_file; ------------------------------------------------- with Corba; with egg_file; package chicken_file.Chicken is type Ref is new Chicken_Ref with null record; function lay (Self : Ref) return egg_file.Egg_Ref'Class; -- returns a egg_file.Egg.Ref end chicken_file.Chicken; ------------------------------------------------- with Corba; with egg_file.Egg; package chicken_file.Chicken.Impl is type Object is new Corba.Object with record -- (implementation data) end record; function lay (Self : in Object) return Egg.Ref'Class; end chicken_file.Chicken.Impl; ------------------------------------------------- with Corba; package egg_file is type Egg_Ref is new Corba.Ref with null record; end egg_file; ------------------------------------------------- with Corba; with chicken_file; package egg_file.Egg is type Ref is new Egg_Ref with null record; function hatch (Self : Ref) return chicken_file.Chicken_Ref'Class; -- returns a chicken_file.Chicken.Ref end egg_file.Egg; ------------------------------------------------- with Corba; with chicken_file.Chicken; package egg_file.Egg.Impl is type Object is new Corba.Object with record -- (implementation data) end record; function hatch (Self : in Object) return Chicken.Ref'Class; end egg_file.Egg.Impl; No with'ing problems here! ... Bill -- e-mail: Bill.Beckwith@ois.com | Team Ada Objective Interface Systems, Inc. | dist, full O-O 1895 Preston White Drive, Suite 250 | multithreading Reston, VA 22091-5448 U.S.A. | built in