comp.lang.ada
 help / color / mirror / Atom feed
From: Ed Falis <efalis@mediaone.net>
Subject: Re: Who is wrong, me or GNAT? :-)
Date: Sat, 22 Dec 2001 19:28:27 GMT
Date: 2001-12-22T19:28:27+00:00	[thread overview]
Message-ID: <3C24DF92.7040205@mediaone.net> (raw)
In-Reply-To: c25V7.2353$8L1.26553@rwcrnsc52

Mark Lundquist wrote:

> OK, here's the code:
> 
> --------------------------------------------
> -- foo.adb
> --------------------------------------------
> 
>  procedure Foo is
> 
>   package P is
>    type T is abstract tagged null record;
>    function Create return T is abstract;
>   end P;
> 
> 
>   package P1 is
>    type T2 is new P.T with private;
>   private
>    type T1 is new P.T with null record;
>    function Create return T1;
> 
>    type T2 is new T1 with null record;
>    --
>    -- Gnat takes error on this ^^^ line.
>    --
>    -- But T2 should inherit 'Create' from
>    -- (concrete) type T1.
> 
>   end P1;
> 
>   package body P1 is
>    function Create return T1 is
>    begin
>     return (null record);
>    end Create;
>   end P1;
> 
>  begin
>   null;
>  end Foo;
> ----------------------------------------
> 
> GNAT 3.13(p) says:
> foo.adb:16:30: type must be declared abstract or "Create" overridden
> 
> Is this a bug in GNAT?  If not, what am I missing?
> 
> I was trying to come up with an idiom for inherited constructors for
> descendants of an abstract tagged type, and this seemed like it ought to do
> the trick (although it suffers from the fact that the intermediate derived
> type, e.g. T1 in this case, would have to override all the abstract
> primitives).
> 
> Any help appreciated...
> thx
> -- mark

RM 3.9.3 (4-6)

Functions with a controlling result must be explicitly overridden when 
the parent type is derived (or the derived type has to be declared 
abstract), as they're considered abstract in the derived type.




  reply	other threads:[~2001-12-22 19:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-22 19:20 Who is wrong, me or GNAT? :-) Mark Lundquist
2001-12-22 19:28 ` Ed Falis [this message]
2001-12-22 21:14   ` Mark Lundquist
2001-12-27 15:39 ` Matthew Heaney
replies disabled

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