From: Tucker Taft <stt@averstar.com>
Subject: Re: generic formal derived type that inherits private op
Date: 1999/11/12
Date: 1999-11-12T00:00:00+00:00 [thread overview]
Message-ID: <382C85D9.E411A4CB@averstar.com> (raw)
In-Reply-To: 382b8c0b_1@news1.prserv.net
Matthew Heaney wrote:
>
> There's some code below that I think should work, but doesn't:
>
> 1) A generic child package imports a generic formal type that derives
> from a (tagged) type declared in the parent package.
>
> 2) The parent type declares a primitive operation privately; that is, in
> the private region of the parent package.
>
> 3) The generic child package tries to call the (private) primitive
> operation of the derived type, but the compiler doesn't think the
> derived type comes with that operation. This appears to be incorrect.
>
> Here's the output of my compiler (GNAT v3.12p):
>
> p-c.adb:5:19: expected type access to "T" defined at p.ads:9
> p-c.adb:5:19: found type access to "Nt" defined at p-c.ads:5
>
> What's the scoop? Is this correct or not?
Your code is correct. The compiler seems to have a bug
(and the ACVC suite seems to have a hole in this area).
>
> (Tucker: I submitted this same code to CLA a few months ago. Remember
> we talked about it at the ARG meeting a few weeks ago?)
Yes, and we had pretty much the same problem in our compiler, which
we have since fixed. So now My Favorite Ada95 Front End likes your
code. ;-)
>
> Thanks,
> Matt
>
> --STX
> package P is
>
> type T is abstract tagged limited private;
>
> private
>
> type T is abstract tagged limited null record;
>
> procedure Private_Op (O : access T);
>
> end P;
>
> package body P is
>
> procedure Private_Op (O : access T) is
> begin
> null;
> end;
>
> end P;
>
> generic
> type NT is new T with private;
> package P.C is
>
> procedure Op (O : access NT);
>
> end P.C;
>
> package body P.C is
>
> procedure Op (O : access NT) is
> begin
> Private_Op (O);
> end Op;
>
> end P.C;
--
-Tucker Taft stt@averstar.com http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.) Burlington, MA USA
prev parent reply other threads:[~1999-11-12 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-11 0:00 generic formal derived type that inherits private op Matthew Heaney
1999-11-12 0:00 ` Tucker Taft [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