comp.lang.ada
 help / color / mirror / Atom feed
From: Robert_Matthews <ignored@ramatthews.free-online.co.uk>
Subject: Re: A problem with "interface"
Date: Fri, 06 Feb 2009 14:08:17 +0000
Date: 2009-02-06T14:08:17+00:00	[thread overview]
Message-ID: <h5CdnXIxttLS2RHUnZ2dnUVZ8vSdnZ2d@posted.plusnet> (raw)
In-Reply-To: b536e8fe-d10b-41a4-847c-05ee4c90bd00@y23g2000pre.googlegroups.com

Adam Beneschan wrote:

> You're making a mistake, but I'm hesitant to call it a "dumb" one.
> When you declare Client_A, the package implicitly declares inherited
> operations, which are inherited from primitive operations of Int.A.
> One of those is Client_P, and so you'll get this *implicit*
> declaration;
> 
>    procedure Client_P (Param1 : Client_A;  Param2 : Int.B'Class);
> 
> Since Client_A is derived from Int.A, all uses of "A" in the profile
> are replaced by Client_A.  But "B" isn't touched.
> 
> Note that nothing is inherited when you declare Client_B.  Client_P is
> a primitive operation of Int.A but *not* of Int.B (since its parameter
> is B'Class, not B).
> 
> When you declare an overriding procedure, the procedure has to
> override something that is implicitly declared.  The only implicitly
> declared procedure is the one I showed above; its second parameter has
> type Int.B'Class, not Client_B'Class, and therefore the procedure you
> declared can't override it.
> 
> The way to do this is to declare your procedure with "Param2 :
> Int.B'Class"; then in the body of Client_P, you can say something like
> 
>    if Param2 not in Client_B'Class then
>       raise <some_exception> with "Wrong client type";
>    end if;
> 
>                                  -- Adam

Many thanks for putting me right on this - though on a second
look I see I made yet another dumb mistake: in the package "Client"
the procedure should be called "P" rather than "Client_P".

Clearly senility is taking its toll!

Robert




      reply	other threads:[~2009-02-06 14:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05 15:05 A problem with "interface" Robert_Matthews
2009-02-05 16:13 ` Jacob Sparre Andersen
2009-02-05 16:14 ` Adam Beneschan
2009-02-06 14:08   ` Robert_Matthews [this message]
replies disabled

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