comp.lang.ada
 help / color / mirror / Atom feed
* generic formal derived type that inherits private op
@ 1999-11-11  0:00 Matthew Heaney
  1999-11-12  0:00 ` Tucker Taft
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Heaney @ 1999-11-11  0:00 UTC (permalink / raw)


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?

(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?)

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;




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: generic formal derived type that inherits private op
  1999-11-11  0:00 generic formal derived type that inherits private op Matthew Heaney
@ 1999-11-12  0:00 ` Tucker Taft
  0 siblings, 0 replies; 2+ messages in thread
From: Tucker Taft @ 1999-11-12  0:00 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-11-12  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-11  0:00 generic formal derived type that inherits private op Matthew Heaney
1999-11-12  0:00 ` Tucker Taft

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