comp.lang.ada
 help / color / mirror / Atom feed
From: Eric G. Miller <egm2@jps.net>
Subject: Arrays and Access types...
Date: Thu, 25 Oct 2001 21:46:47 -0700
Date: 2001-10-25T21:46:47-07:00	[thread overview]
Message-ID: <20011025214647.2788a60b.egm2@jps.net> (raw)


New to Ada and trying to figure out how to deal with arbitrary
slices of arrays.  I defined an array type and an access type
for it, but I can't seem to figure out how to take a slice of
the array and assign that slice to an access type.

Type is like:

type My_Array is array (Positive range <>) of Integer;
type My_Array_Ref is access My_Array;

... in body ...

left, right, start : My_Array_Ref;

begin
    start := new My_Array (1 .. 200);
    left  := start(start'first .. 100); -- that doesn't work!
...

The first is allowed, whereas I can't figure out how to
make second an access type assignment (is it possible?).

What I want to do is progressively subset the array, and I
won't know exactly how it'll get broken up until runtime.  The
original array will get divvied up into smaller and smaller
slices of an earlier slice (the remaining can be discarded).

If there's a way to do this with regular arrays (no access
types), that'll work.  I wanted to minimize the number of
"new" arrays -- I'm not quite comfortable with how/when to
use Unconstrained_Deallocation yet...

-- 
Eric G. Miller <egm2@jps.net>



             reply	other threads:[~2001-10-26  4:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26  4:46 Eric G. Miller [this message]
2001-10-26  5:39 ` Arrays and Access types James Rogers
2001-10-26  6:45   ` Eric G. Miller
2001-10-26 16:40     ` James Rogers
2001-10-26  6:14 ` tmoran
2001-10-26 14:26 ` Ted Dennison
2001-10-26 19:31 ` chris.danx
2001-10-26 23:32 ` Jeffrey Carter
2001-10-27  1:08 ` Eric G. Miller
2001-10-27  2:09   ` DuckE
2001-10-27  4:23     ` Steven Deller
2001-10-27 18:30       ` Eric G. Miller
replies disabled

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