From: NiGHTS <nights@unku.us>
Subject: Pointer to instance of indefinite array?
Date: Tue, 12 Aug 2014 19:07:05 -0700 (PDT)
Date: 2014-08-12T19:07:05-07:00 [thread overview]
Message-ID: <892c6798-489d-400a-bb9a-7a14605c493f@googlegroups.com> (raw)
Suppose I have a package like this...
package Test_Package is
type Element is
record
ID_1 : Positive;
ID_2 : Positive;
end record;
type Element_Array is array (Positive range <>) of Element;
type Element_Array_Ptr is access Element_Array;
procedure Do_Something_With_Array (
In_Array : in Element_Array_Ptr
);
end Test_Package;
In this situation I have an array of "Element" records with an unknown number of elements. The number of elements are to be defined by the user of this package and passed as a pointer to the procedure "Do_Something_With_Array".
So a simple implementation would be something like this...
with Test_Package; use Test_Package;
procedure main is
Test_Array : aliased Element_Array (1 .. 20);
begin
-- Initialize the array, then call this function...
Do_Something_With_Array (In_Array => Test_Array'Access);
end main;
So this does not compile and with countless errors no matter what configuration I try. I have a feeling my approach is fundamentally wrong. Essentially I am trying to pass a constrained array to a package accepting an array of any length, both of the same element type. I would parse the contents of this array using "for in" or 'First -> 'Last or 'Range.
What is the best way to achieve this goal without using new / free?
next reply other threads:[~2014-08-13 2:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 2:07 NiGHTS [this message]
2014-08-13 2:09 ` Pointer to instance of indefinite array? Jeffrey Carter
2014-08-13 2:29 ` Shark8
2014-08-13 3:06 ` NiGHTS
2014-08-13 4:28 ` Jeffrey Carter
2014-08-13 16:06 ` NiGHTS
2014-08-13 17:43 ` Jeffrey Carter
2014-08-13 17:58 ` Shark8
2014-08-13 18:36 ` Dmitry A. Kazakov
2014-08-13 4:31 ` Per Sandberg
2014-08-13 7:47 ` Georg Bauhaus
2014-08-13 8:05 ` Egil H H
2014-08-13 15:32 ` Adam Beneschan
2014-08-14 8:03 ` Georg Bauhaus
2014-08-13 18:17 ` Niklas Holsti
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox