comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <list_email@icloud.com>
Subject: Trying to declare an array from the heap from inside a record declaration
Date: Wed, 8 Nov 2017 01:32:30 -0800 (PST)
Date: 2017-11-08T01:32:30-08:00	[thread overview]
Message-ID: <1c20fe22-ba3c-4db4-a18d-c922e3d04de5@googlegroups.com> (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


             reply	other threads:[~2017-11-08  9:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  9:32 Jerry [this message]
2017-11-08 13:08 ` Trying to declare an array from the heap from inside a record declaration 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
replies disabled

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