comp.lang.ada
 help / color / mirror / Atom feed
* Generic Formal With Discrim Used As Actual - How?
@ 1998-10-25  0:00 Matthew Heaney
  1998-10-25  0:00 ` Tucker Taft
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Heaney @ 1998-10-25  0:00 UTC (permalink / raw)


I'm having trouble passing generic formal types --one of which has an
access discriminant-- as generic actuals to another generic having an
identical profile.  Something like:

generic
   type T1 (<>) is limited private;
   type T2 (O : access T1) is limited private;
procedure GP;

generic
   type T1 (<>) is limited private;
   type T2 (O : access T1) is limited private;
procedure GQ;

with GQ;
procedure GP is
  procedure Q is new GQ (T1, T2);
begin
   null;
end GP;


When I try to compile the body of GP, I get the following message:

(start of compiler message)
gnatf /home/matt/acl/rings/gp.adb
gp.adb:4:30: types of actual discriminants must match formal
gp.adb:4:30: instantiation abandoned

Compilation exited abnormally with code 1 at Sun Oct 25 01:13:09
(end of compiler message)


Can someone explain what's going on here?  Why doesn't this code compile?

Is there any way to pass a formal type with a discriminant as the actual
type of another instantiation?

Thanks,
Matt






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

* Re: Generic Formal With Discrim Used As Actual - How?
  1998-10-25  0:00 Generic Formal With Discrim Used As Actual - How? Matthew Heaney
@ 1998-10-25  0:00 ` Tucker Taft
  0 siblings, 0 replies; 2+ messages in thread
From: Tucker Taft @ 1998-10-25  0:00 UTC (permalink / raw)


Matthew Heaney (matthew_heaney@acm.org) wrote:

: I'm having trouble passing generic formal types --one of which has an
: access discriminant-- as generic actuals to another generic having an
: identical profile.  

I believe you have bumped into a compiler bug.  My favorite Ada 95
front end has no problem with your code.

: ... Something like:

: generic
:    type T1 (<>) is limited private;
:    type T2 (O : access T1) is limited private;
: procedure GP;

: generic
:    type T1 (<>) is limited private;
:    type T2 (O : access T1) is limited private;
: procedure GQ;

: with GQ;
: procedure GP is
:   procedure Q is new GQ (T1, T2);
: begin
:    null;
: end GP;


: When I try to compile the body of GP, I get the following message:

: (start of compiler message)
: gnatf /home/matt/acl/rings/gp.adb
: gp.adb:4:30: types of actual discriminants must match formal
: gp.adb:4:30: instantiation abandoned

This may be due to the fact that each access discriminant conceptually
declares a new access type.  However, subtype matching is
defined in the RM so as to bypass this problem, but perhaps your
compiler is falling into the trap.

: Compilation exited abnormally with code 1 at Sun Oct 25 01:13:09
: (end of compiler message)


: Can someone explain what's going on here?  Why doesn't this code compile?

: Is there any way to pass a formal type with a discriminant as the actual
: type of another instantiation?

You are doing the right thing.  Your compiler is tripping over it...

You might try using a named access type rather than an anonymous
access type for the discriminant, and see whether your compiler swallows it.

: Thanks,
: Matt

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




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

end of thread, other threads:[~1998-10-25  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-25  0:00 Generic Formal With Discrim Used As Actual - How? Matthew Heaney
1998-10-25  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