Re: Problem with generic parameter



generic
    type Indices is (<>);
package Generic_Root
    type Measurement is array (Indices) of Measurement;

The reason that I don't do that is that that would have to instantiate a copy of Generic_Root _and_ Generic_Root.Child for each choice of array indices.

No you don't. (The above example was misleading.)

generic
   type Indices is (<>);
package Generic_Root.Child_By_Marius is
   type Measurement_Array is
      array (Indices range <>) of Measurement;
end;

with Generic_Root;
with Generic_Root.Child_By_Marius;
procedure Marius_Demo is
   type Scalar is digits 15;
   package Measurements is
      new Generic_Root (Scalar => Scalar);
   package Measurements_Text_IO is
      new Measurements.Child_By_Marius
        (Indices => Positive);
   use Measurements_Text_IO;               --|
   Array_1 : Measurement_Array (1 .. 10);  --| *HERE*
   Array_2 : Measurement_Array (2 .. 20);  --|
begin
   null;
end;

.



Relevant Pages

  • Re: C bindings, Interfaces.C.Pointers etc.
    ... standard array notation. ... I have used a generic package to create the appropriate ... pragma Convention; ... end CArrayUtils; ...
    (comp.lang.ada)
  • Re: Accessing data in embedded class object WMI ACPI sample from DDK
    ... set the properties of a Package class object. ... as it's property an array. ... execute the SetPackage or GetPackage methods but am confused about how to ... > const BSTR PackageInst = ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Help! mem leak in c extension.
    ... But I guess the non specificity of the progs and specially the ... through simple disciplines of measurement and ... array as a tcl array or as a list. ...
    (comp.lang.tcl)
  • Re: Packages and returning errors
    ... The perldoc function guide says about shift (which is ... "Shifts the first value of the array off and returns it, ... If an array of values are passed to a sub, ... Back to my package (which I am currently thinking might be out of my depth, ...
    (comp.lang.perl.misc)
  • Unconstrained array of unconstrained vector.
    ... Is there a way (in VHDL93) to define an array of vectors in a package ... The advantage is having a set of packages with self contained routines ...
    (comp.lang.vhdl)

Loading