comp.lang.ada
 help / color / mirror / Atom feed
* Trying to declare an array from the heap from inside a record declaration
@ 2017-11-08  9:32 Jerry
  2017-11-08 13:08 ` AdaMagica
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jerry @ 2017-11-08  9:32 UTC (permalink / raw)


Several years ago a kind and clever person on this list showed me how to allocate possibly large arrays from the heap without breaking functions which expect just normal arrays. Using the Numerics features as an example, it might look like this...

M, N : Integer := 100; -- Included here for clarity.
x_Ptr : Real_Vector_Access := new Real_Vector(M .. N);
    x : Real_Vector renames x_Ptr.all;

... and subprograms which expect a Real_Vector have no problems with this x.

Now, I want to put this kind of thing inside a record declaration, but the compiler complains. I'm trying this:

type foo(M, N : Integer) is
    record
        y : Real_Vector(M .. N);
        x_Ptr : Real_Vector_Access := new Real_Vector(M .. N);
            x : Real_Vector renames x_Ptr.all;
    end record;

y is accepted as OK but the x_Ptr line generates "unconstrained subtype in component declaration" and the next line generates "missing ";"".

Jerry


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

end of thread, other threads:[~2017-11-14 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08  9:32 Trying to declare an array from the heap from inside a record declaration Jerry
2017-11-08 13:08 ` AdaMagica
2017-11-08 17:22 ` Jeffrey R. Carter
2017-11-10  7:44 ` Jerry
2017-11-10  8:10   ` AdaMagica
2017-11-14 15:19     ` Robert Eachus

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