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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f071b0868ee342f X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Design Question: How Best To Structure Cross-Referencing Types In Ada 95 Date: 1999/01/21 Message-ID: #1/1 X-Deja-AN: 435290865 Sender: matt@mheaney.ni.net References: <36A68FCA.E1EEAFFE@hiwaay.net> NNTP-Posting-Date: Thu, 21 Jan 1999 09:39:57 PDT Newsgroups: comp.lang.ada Date: 1999-01-21T00:00:00+00:00 List-Id: "Anthony E. Glover" writes: > Is there a neat Ada95 way of getting around this cross-referencing > problem? You have to forward declare one of the types, which you'll have to make tagged: package Root_Cars is type Root_Car is abstract tagged null record; end Root_Cars; with Root_Cars; use Root_Cars; package Parts is type Part is private; procedure Activate (The_Part : Part); private type Car_Access is access all Root_Car'Class; type Part is record Parent_Car : Car_Access; end record; end Parts; with Root_Cars; use Root_Cars; with Parts; use Parts; package Cars is type Car is new Root_Car with private; procedure Install (On : Car; The_Part : Part); private type Car is record Part1 : Part; Part2 : Part; end record; end Cars; Now, in the body of Parts, just down-cast to the normal car type: with Cars; package body Parts is procedure Activate (The_Part : in Part) is The_Car : Car renames Car (The_Part.Car.all); begin ... end; end Parts; You don't have to worry the Tag_Check failing, because only type Cars.Car derives from Root_Cars.Root_Car. If this check bothers you, then just disable it: procedure Activate (The_Part : in Part) is pragma Suppress (Tag_Check); The_Car : Car renames Car (The_Part.Car.all); begin ... end;