comp.lang.ada
 help / color / mirror / Atom feed
* Inner generic package derivation
@ 2001-11-16  0:00 Nick Roberts
  2001-11-16  0:41 ` Matthew Heaney
  2001-11-16  3:06 ` Mark Lundquist
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Roberts @ 2001-11-16  0:00 UTC (permalink / raw)


When given the following:

   generic package Test2 is
      type T is abstract tagged limited private;
      procedure P (X: in T) is abstract;
      generic package Inner is
         type U is new T with private;
         procedure Q (X: in T);
      private
         type U is new T with -- error line
            record
               C: Integer;
            end record;
      end Inner;
   private
      type T is abstract tagged limited null record;
   end Test2;

GNAT 3.12p on Windows 95 gives the error:

   premature derivation of derived or private type

Is this a bug in: (a) GNAT; (b) the RM95; or (c) my brain?

Full detailed explanation welcome (if applicable).

--
Best wishes,
Nick Roberts






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

* Re: Inner generic package derivation
  2001-11-16  0:00 Inner generic package derivation Nick Roberts
@ 2001-11-16  0:41 ` Matthew Heaney
  2001-11-16  1:54   ` Nick Roberts
  2001-11-16  3:06 ` Mark Lundquist
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Heaney @ 2001-11-16  0:41 UTC (permalink / raw)



"Nick Roberts" <nickroberts@adaos.worldonline.co.uk> wrote in message
news:9t1lp3$16unne$2@ID-25716.news.dfncis.de...
>    premature derivation of derived or private type
>
> Is this a bug in: (a) GNAT; (b) the RM95; or (c) my brain?

No, this is not a bug.  You can't declare the full view of type U until
after the declaration of the full view of type T.

That's why this is legal:

package P is
   type T is tagged private;
   type NT is new T with private;
private
   type T is tagged null record;
   type NT is new T with null record;
end;

and this is not legal:

package P is
   type T is tagged private;
   type NT is new T with null record;
private
   type T is tagged null record;
end;







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

* Re: Inner generic package derivation
  2001-11-16  0:41 ` Matthew Heaney
@ 2001-11-16  1:54   ` Nick Roberts
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 2001-11-16  1:54 UTC (permalink / raw)


Thanks, Matt.

However, I also want to know: (a) exactly what combination of rules in the
RM95 enforce it; (b) why.

--
Best wishes,
Nick Roberts



"Matthew Heaney" <mheaney@on2.com> wrote in message
news:tv8nulpg5eni2c@corp.supernews.com...
>
> "Nick Roberts" <nickroberts@adaos.worldonline.co.uk> wrote in message
> news:9t1lp3$16unne$2@ID-25716.news.dfncis.de...
> >    premature derivation of derived or private type
> >
> > Is this a bug in: (a) GNAT; (b) the RM95; or (c) my brain?
>
> No, this is not a bug.  You can't declare the full view of type U until
> after the declaration of the full view of type T.
>
> That's why this is legal:
>
> package P is
>    type T is tagged private;
>    type NT is new T with private;
> private
>    type T is tagged null record;
>    type NT is new T with null record;
> end;
>
> and this is not legal:
>
> package P is
>    type T is tagged private;
>    type NT is new T with null record;
> private
>    type T is tagged null record;
> end;






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

* Re: Inner generic package derivation
  2001-11-16  0:00 Inner generic package derivation Nick Roberts
  2001-11-16  0:41 ` Matthew Heaney
@ 2001-11-16  3:06 ` Mark Lundquist
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Lundquist @ 2001-11-16  3:06 UTC (permalink / raw)



>
> GNAT 3.12p on Windows 95 gives the error:
>
>    premature derivation of derived or private type
>
> Is this a bug in: (a) GNAT; (b) the RM95; or (c) my brain?

That would be (c)... :-)

>
> Full detailed explanation welcome (if applicable).

See RM 3.4(4).  You get the same error message with this:

package Foo is
    type T1 is private;
    type T2 is new T1;
private
    type T1 is null record;
end Foo;

-- mark






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

end of thread, other threads:[~2001-11-16  3:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-16  0:00 Inner generic package derivation Nick Roberts
2001-11-16  0:41 ` Matthew Heaney
2001-11-16  1:54   ` Nick Roberts
2001-11-16  3:06 ` Mark Lundquist

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