comp.lang.ada
 help / color / mirror / Atom feed
* Having a problem with private extension and discriminants...
@ 1999-07-21  0:00 westonpa
  1999-07-22  0:00 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: westonpa @ 1999-07-21  0:00 UTC (permalink / raw)


Hi,

I am trying to indirectly derive from a tagged type that has known 
discriminants, but GNAT gives the error 
"full view must inherit discriminants of the parent type used in the 
private extension". This looks like ARM 7.3(10). Does anyone have an idea 
how I can achieve the following? 


package P1 is 
   type A(Foo : Natural) is abstract tagged null record;

private
  
   type B is abstract new A with
      record
	-- private fields here
      end record;

end P1;



package P1.C1 is 
  
   type C is new A with private;

private
   type C is new B with
      record 
        -- more fields in addition to B's
      end record;

end P1.C1;


package P1.C2 is

   -- similar to what is in P1.C1

end P1.C2;






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

* Re: Having a problem with private extension and discriminants...
  1999-07-22  0:00 ` Florian Weimer
@ 1999-07-22  0:00   ` Weston T. Pan
  0 siblings, 0 replies; 3+ messages in thread
From: Weston T. Pan @ 1999-07-22  0:00 UTC (permalink / raw)


Florian Weimer wrote:

> Perhaps this is a solution:
> 
> package P1.C1 is
> 
>    type C (Foo : Natural) is new A with private;
> 
> private
>    type C (Foo : Natural) is new B (Foo) with
>       record
>         -- more fields in addition to B's
>       end record;
> 
> end P1.C1;

Hi, 

I thought about doing that, but I wanted to see if it was possible to
not give
any indication that something else was being done in the  private
section. 
For example, in the case where there is no discriminants, a person can
do
the following:

package P1 is
    type A is abstract tagged with null record;

private 
    type B is abstract new A with 
       record
         -- blah blah
       end record;
end P1;


package P1.C1 is
     type C is new A with private;

private
     type C is new B with
        record
          -- blah
        end record;
end P1.C1;


In the above there is no indication in the public part that there is
something else
happening in the private section. Oh well, I guess I will just add the
discriminant
to C. I prefer doing that than making the type B into a record and
having C contain 
a field of type B. 

Thank you for your suggestion.

--Weston




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

* Re: Having a problem with private extension and discriminants...
  1999-07-21  0:00 Having a problem with private extension and discriminants westonpa
@ 1999-07-22  0:00 ` Florian Weimer
  1999-07-22  0:00   ` Weston T. Pan
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 1999-07-22  0:00 UTC (permalink / raw)


westonpa@aludra.usc.edu (westonpa) writes:

> package P1 is 
>    type A(Foo : Natural) is abstract tagged null record;
> 
> private
>   
>    type B is abstract new A with
>       record
> 	-- private fields here
>       end record;
> 
> end P1;

> package P1.C1 is 
>   
>    type C is new A with private;
> 
> private
>    type C is new B with
>       record 
>         -- more fields in addition to B's
>       end record;
> 
> end P1.C1;

Perhaps this is a solution:

package P1.C1 is

   type C (Foo : Natural) is new A with private;

private
   type C (Foo : Natural) is new B (Foo) with
      record
        -- more fields in addition to B's
      end record;

end P1.C1;




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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-21  0:00 Having a problem with private extension and discriminants westonpa
1999-07-22  0:00 ` Florian Weimer
1999-07-22  0:00   ` Weston T. Pan

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