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,c9a5d6b3975624e1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-06 02:29:41 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!dialin-145-254-047-082.arcor-ip.NET!not-for-mail From: Dmitry A.Kazakov Newsgroups: comp.lang.ada Subject: Re: OO in Ada Date: Sun, 6 Oct 2002 23:37:20 +0200 Message-ID: References: <3D9E3018.8000403@worldnet.att.net> <3D9F0411.50704@worldnet.att.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-047-082.arcor-ip.net (145.254.47.82) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1033896580 16999049 145.254.47.82 (16 [77047]) User-Agent: KNode/0.4 Xref: archiver1.google.com comp.lang.ada:29540 Date: 2002-10-06T23:37:20+02:00 List-Id: Jim Rogers wrote: > Dmitry A.Kazakov wrote: > >> Jim Rogers wrote: >> >>>I disagree here. Ada does not give the illusion of multiple dispatch. >>> >> Would "limited multiple dispatch" sound better? >> >>>An Ada subprogram can only be primitive to one type. That characteristic >>>is determined by the place in the source code where the subprogram >>>interface is defined. >> >> This is wrong. Technically you could do it, because type declaration >> areas [before freezing point] may overlap: > > I must again diagree. You are wrong. Section 3.9 paragraph 12 of the Ada > Reference Manual states: > > "A given subprogram shall not be a dispatching operation of two or more > distinct tagged types." You missed the point. I didn't challenged this rule. I said that it is wrong to think that this rule might be a consequence of the rules controlling the place in the source code where a primitive operation is allowed to be declared. I showed that this is wrong. For two different types there can be a place where one could define a primitive operation for any of them: >> type A is tagged ... >> type B is tagged ... >> procedure Multiple_Dispatch (X : A; Y : B); -- Alas, compilation error > There is a compilation error. Look at what it says. Gnat 3.14p states > "operation can be dispatching in only one type." Yes, but not because of "a primitive operation is declared too late". That's the point. > This does not provide any for of multiple dispatch, limited or otherwise. This does not, because it is illegal. But Ada 95 does have multiple dispatch, because of: type A is tagged ... procedure Multiple_Dispatch (X, Y : A); This is a case of multiple dispatch because more than one parameter is dispatching. It is a limited multiple dispatch because: 1. In the dispatch table [note, table, not a vector like in C++! *] of Multiple_Dispatch only diagonal elements can be overridden. Non-diagonal elements are final and predefined as raising Constraint_Error. 2. The types associated with the rows and columns of the table have to have a common ancestor. (*) Of course, you can implement this table using a vector. -- Regards, Dmitry Kazakov www.dmitry-kazakov.de