comp.lang.ada
 help / color / mirror / Atom feed
* Problem with generic parameter
@ 2005-06-22 10:21 Jacob Sparre Andersen
  2005-06-22 11:16 ` Martin Dowie
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jacob Sparre Andersen @ 2005-06-22 10:21 UTC (permalink / raw)


When I try to compile the program included below (cut down version of
a test program) GNAT 3.15p reports:

-----
Compiling: demo.adb (source file time stamp: 2005-06-22 10:10:41)

    16.                               Measurement_Array => Measurement_Array);
                                                           |
        >>> component subtype of actual does not match that of formal "Measurement_Array"
        >>> instantiation abandoned

 20 lines: 2 errors
-----

I can't see _how_ it doesn't match.  Can somebody figure out what I'm
doing wrong?  And maybe even suggest me an elegant solution to the
problem?

The reason I have Measurement_Array as a generic parameter is that I
also use it elsewhere, and that I may want to work with differently
indexed measurement arrays.  Does it - despite that - make more sense
to declare the types "Measurement" and "Measurement_Array" together?

/Jacob

------------------------------------------------------------------------------
--  Source code:

with Generic_Root;
with Generic_Root.Child;

procedure Demo is

   type Scalar is digits 15;

   package Measurements is
      new Generic_Root (Scalar => Scalar);

   type Measurement_Array is array (Positive range <>)
     of Measurements.Measurement;

   package Measurement_Text_IO is
      new Measurements.Child (Indices           => Positive,
                              Measurement_Array => Measurement_Array);

begin
   null;
end Demo;

generic

   type Scalar is digits <>;

package Generic_Root is

   ---------------------------------------------------------------------------
   --  type Limit:

   type Limit is (Below, Exact, Above, Undefined);

   ---------------------------------------------------------------------------
   --  type Measurement:

   type Measurement (As : Limit := Exact) is
      record
         case As is
            when Below | Exact | Above =>
               Value : Scalar;
            when Undefined =>
               null;
         end case;
      end record;

   ---------------------------------------------------------------------------

end Generic_Root;

with Ada.Text_IO;

generic

   type Indices is (<>);

   type Measurement_Array is array (Indices range <>) of Measurement;

package Generic_Root.Child is

end Generic_Root.Child;



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

end of thread, other threads:[~2005-06-22 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-22 10:21 Problem with generic parameter Jacob Sparre Andersen
2005-06-22 11:16 ` Martin Dowie
2005-06-22 11:58 ` Marius Amado Alves
2005-06-22 13:09   ` Jacob Sparre Andersen
2005-06-22 14:26     ` Marius Amado Alves
     [not found] ` <f6af3631a69872fe2f46258f86b08473@netcabo.pt>
2005-06-22 12:43   ` Marius Amado Alves

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