comp.lang.ada
 help / color / mirror / Atom feed
From: "Sergey Koshcheyev" <serko84@hotmail.com>
Subject: Re: Ambiguous reference - What is wrong with this?
Date: Tue, 14 Aug 2001 19:44:13 +0200
Date: 2001-08-14T19:44:13+02:00	[thread overview]
Message-ID: <9lbo1h$2bhq$1@ns.felk.cvut.cz> (raw)
In-Reply-To: 9lbf8n$brf$1@nh.pace.co.uk

Hi!

"Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org> 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








  parent reply	other threads:[~2001-08-14 17:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-14 15:14 Ambiguous reference - What is wrong with this? Marin David Condic
2001-08-14 16:56 ` Warren W. Gay VE3WWG
2001-08-14 17:45   ` Warren W. Gay VE3WWG
2001-08-14 17:54   ` Marin David Condic
2001-08-14 19:24     ` Warren W. Gay VE3WWG
2001-08-14 17:44 ` Sergey Koshcheyev [this message]
2001-08-14 20:10   ` Marin David Condic
2001-08-15  7:38     ` Sergey Koshcheyev
2001-08-15 13:49       ` Marin David Condic
2001-08-14 20:02 ` tmoran
2001-08-15  6:17   ` Simon Wright
2001-08-17 16:34     ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox