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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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:00:50 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!dialin-145-254-036-184.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to test object hierarchy Date: Fri, 19 Dec 2003 18:07:05 +0100 Organization: At home Message-ID: References: <93172edb.0312181024.9a536b2@posting.google.com> <1071844528.57052@master.nyc.kbcfp.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-036-184.arcor-ip.net (145.254.36.184) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 1071853249 8340378 145.254.36.184 ([77047]) User-Agent: KNode/0.7.2 Xref: archiver1.google.com comp.lang.ada:3565 Date: 2003-12-19T18:07:05+01:00 List-Id: Hyman Rosen wrote: > Dmitry A. Kazakov wrote: >> You have to override Test_Hierarchy for each new type > > Which brings a question to my non Ada-knowing mind. > I know that for a subprogram to be dispatching, it > must be defined in the same package (or immediately > after?) as the tagged type upon which it dispatches. Before the freezing point, which is informally at the first "non-trivial" use of the type before the package specification end. > Can an instantiation of a generic be dispatching in > this way? Could I do (pardon the syntax errors) > procedure Test_Hierarchy is new > Generic_Test_Hierarchy(Type1=>Derived_Object); > rather than copy the code each time? Aside, it is actually what inheritance is for! The problem is that there is no [proper] multiple dispatch in Ada. Well, an implementation of a dispatching subprogram through instantiation of a generic one is not allowed in either Ada or C++. One step up. A generic primitive operation is also not allowed in both. Another step up. Generic types do exist in C++, but not in Ada, where same effect is achieved using generic packages. A strategic question is, whether one realy should exploit all possible combinations of inheritance [and all other language things] and generics. You know my opinion, down with generics! And there will be no question anymore! (:-)) -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de