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-22 02:02:55 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!dialin-145-254-042-178.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to test object hierarchy Date: Mon, 22 Dec 2003 11:09:12 +0100 Organization: At home Message-ID: References: <93172edb.0312181024.9a536b2@posting.google.com> <49cbf610.0312211158.87338af@posting.google.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-042-178.arcor-ip.net (145.254.42.178) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 1072087373 10020845 145.254.42.178 ([77047]) User-Agent: KNode/0.7.2 Xref: archiver1.google.com comp.lang.ada:3692 Date: 2003-12-22T11:09:12+01:00 List-Id: Robert I. Eachus wrote: > Dmytry Lavrov wrote: > >>>I think that IF Ada should have multiple dispatch on different types... > > In Ada, if and where you need it, you can get multiple dispatching. > There are of course many different patterns that correspond to multiple > dispatching, and if you want the most general pattern: > > function "+" (L, R: Object) return Object; > > Where unlike normal Ada, L, R and the return value can be different > specific types. This can be done, but you actually have to do some > extra work "under the covers." > > Normally you would declare the visible "+" as: > > function "+" (L: Object; R: Object'Class) return Object'Class; > > Then in the private part you would have a function which is called by > the visible "+" but dispatches on the second parameter, and result type: > > function Add (L: Object'Class; R: Object) return Object; > > Or L may be of some general representation type. But from experience, > doing all this is a lot of work, and you don't want to even think about > extending Object beyond the initial set of specific types. You don't > have to rethink the entire structure when you do that, but it may be the > only way to produce something that is understandable to humans. This is an argument in favor of implementing MD in Ada, I suppose (:-)) -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de