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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d58fe1ff04da7fd7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-14 12:52:13 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-FFM2.ecrc.net!news.cesnet.cz!crax.cesnet.cz!news.felk.cvut.cz!not-for-mail From: "Sergey Koshcheyev" Newsgroups: comp.lang.ada Subject: Re: Ambiguous reference - What is wrong with this? Date: Tue, 14 Aug 2001 19:44:13 +0200 Organization: Czech Technical University Message-ID: <9lbo1h$2bhq$1@ns.felk.cvut.cz> References: <9lbf8n$brf$1@nh.pace.co.uk> NNTP-Posting-Host: q89.dkm.cz X-Trace: ns.felk.cvut.cz 997811058 77370 62.24.82.89 (14 Aug 2001 17:44:18 GMT) X-Complaints-To: usenet@ns.felk.cvut.cz NNTP-Posting-Date: Tue, 14 Aug 2001 17:44:18 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:11935 Date: 2001-08-14T19:44:13+02:00 List-Id: Hi! "Marin David Condic" wrote in message news:9lbf8n$brf$1@nh.pace.co.uk... > O.K. I've got a compilation problem that is most likely due to my > misunderstanding of some language rule. Below is some code that shows a > simplified version of the problem. I'm using Gnat 3.13p on a WinNT PC. > > I'm pretty sure that the problem has something to do with the 'Class > parameters creating some kind of ambiguity - but given that I've fully > qualified the names, it seems like the compiler ought to know which > procedure I meant to call. The quest6ion is twofold: Am I doing something > illegal (if so, what?) and if it *is* illegal, then is there an alternate > way of doing essentially the same thing? (One parameter being of a specific > descendent and the other being a class-wide parameter. The class wide > parameter wants to be an increasingly restrictive subset as you move down > the chain of child packages) It looks to me that the problem is this: when you derive a type from some other type, the derived type gets the primitive operations of the parent. However, the dispatching parameter type (I'm not sure if it's the correct terminology) gets changed from the base type to the derived type. The parameter of type 'Class, on the other hand, remains untouched. What this leads to is this: when you declare Some_Proc for the Derive1 type, it does not override the Some_Proc of Base, but *overloads* it. This means that the type Derive1 has *two* primitive operations, and the type Derive2 has three. They are: procedure Some_Proc (Object : in out Derive2; Object2 : in out Base'Class); procedure Some_Proc (Object : in out Derive2; Object2 : in out Derive1'Class); procedure Some_Proc (Object : in out Derive2; Object2 : in out Derive2'Class); and these are the three operations that the compiler can't choose from. A way to overcome this problem would be to rename the Some_Proc you actually call to some other name. Qualifying the parameters, like Root.Child1.Some_Proc ( Object => Root.Child1.Derive1 (Object), Object2 => Root.Child1.Derive1'Class'(Object2)) ; (note the qualification of Object2) doesn't work. Sergey Koshcheyev