comp.lang.ada
 help / color / mirror / Atom feed
* generic child class
@ 2006-03-07 10:44 nblanpain
  2006-03-07 11:31 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 2+ messages in thread
From: nblanpain @ 2006-03-07 10:44 UTC (permalink / raw)


Hi,
I have a compilation error that i not understand. This is my example :

## Vec package ##
generic
type T_Real is digits <>;
package Vec is
end Vec;

## Mat package ##
with Vec;
generic
with package Vector is new Vec (<>);
package Mat is
end Mat;

## Mat.Child package ##
generic
type T_Tab is array (Integer) of Vector.T_Real;
package Mat.Child is
end Mat.Child;

## Test package ##
with Vec;
with Mat;
with Mat.Child;
package Test is
   package Vec_Float is new Vec (T_Real => Float);
   package Mat_Float is new Mat (Vector => Vec_Float);
   type T_Tableau is array (Integer) of Float;
   package Mat_Child_Float is new Mat_Float.Child (T_Tab => T_Tableau);
---- error !!!!!!!!!!
end Test;

The error message is :
"component subtype of actual does not match that of formal T_Tab "

have you an explaining ?

thanks,




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

* Re: generic child class
  2006-03-07 10:44 generic child class nblanpain
@ 2006-03-07 11:31 ` Dmitry A. Kazakov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry A. Kazakov @ 2006-03-07 11:31 UTC (permalink / raw)


On 7 Mar 2006 02:44:09 -0800, nblanpain@hotmail.com wrote:

> I have a compilation error that i not understand. This is my example :
> 
> ## Vec package ##
> generic
> type T_Real is digits <>;
> package Vec is
> end Vec;
> 
> ## Mat package ##
> with Vec;
> generic
> with package Vector is new Vec (<>);
> package Mat is
> end Mat;
> 
> ## Mat.Child package ##
> generic
> type T_Tab is array (Integer) of Vector.T_Real;
> package Mat.Child is
> end Mat.Child;
> 
> ## Test package ##
> with Vec;
> with Mat;
> with Mat.Child;
> package Test is
>    package Vec_Float is new Vec (T_Real => Float);
>    package Mat_Float is new Mat (Vector => Vec_Float);
>    type T_Tableau is array (Integer) of Float;
>    package Mat_Child_Float is new Mat_Float.Child (T_Tab => T_Tableau);
> ---- error !!!!!!!!!!
> end Test;
> 
> The error message is :
> "component subtype of actual does not match that of formal T_Tab "
> 
> have you an explaining ?

GNAT has numerous bugs in generics. As for your example, one trick I know
works with GNAT 3.15p is:
-----------------------------
with Vec;
generic
   with package Vector is new Vec (<>);
package Mat is
   subtype Mat_Float is Vector.T_Real;
       -- Fake subtype to make "type renaming"
end Mat;
------------------------------
generic
   type T_Tab is array (Integer) of Mat_Float;
      -- Refers to the "rename"
package Mat.Child is
end Mat.Child;
-----------------------------
with Vec;
with Mat;
with Mat.Child;
package Test is
   package Vec_Float is new Vec (T_Real => Float);
   package Mat_Float is new Mat (Vector => Vec_Float);
   type T_Tableau is array (Integer) of Float;
   package Mat_Child_Float is new Mat_Float.Child (T_Tab => T_Tableau);
      -- This should be OK with GNAT 3.15p
end Test;

Alas, at some point this all tricks stop to work. BTW, one "nice" feature
of GNAT is to successfully compile generic specifications and bodies and
then, upon instantiation, to report bugs in already compiled specifications
and bodies.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

end of thread, other threads:[~2006-03-07 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-07 10:44 generic child class nblanpain
2006-03-07 11:31 ` Dmitry A. Kazakov

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