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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,760a0492b97ae06e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-19 09:25:01 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: How to test object hierarchy Date: Fri, 19 Dec 2003 17:25:00 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <93172edb.0312181024.9a536b2@posting.google.com> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1071854700 3822 134.91.1.34 (19 Dec 2003 17:25:00 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Fri, 19 Dec 2003 17:25:00 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: archiver1.google.com comp.lang.ada:3573 Date: 2003-12-19T17:25:00+00:00 List-Id: Dmitry A. Kazakov wrote: : type Derived_Object is new Root_Object with ...; : procedure Test_Hierarchy : ( Obj1 : in Derived_Object; : Obj2 : in Root_Object'Class; : Recursion : Boolean := False : ) is : begin : if Recursion : or else Obj2 not in Derived_Object'Class : or else Obj2 in Derived_Object : then : Do_It (Obj1, Obj2); -- Deal with Obj1 :>= Obj2 : else : Test_Hierarchy (Obj2, Obj1, True); -- Dispatch again : end if; : end Test_Hierarchy; : : You have to override Test_Hierarchy for each new type, but I suppose that : "do something" in your code is dispatching anyway. When Test_Hierarchy is : not commutative it gets a bit more complicated, but I think you have got : the idea. Whenever I see an "if" testing for types I'm wondering whether these ifs should be turned "to the outside" into what they mean in the solution domain, but using language means. Is it really advantageous or necessary to have to do manual dispatching in your program? And I have the same question that Hyman has asked about generics, plus, should "with type" be mentioned in this context? -- Georg