comp.lang.ada
 help / color / mirror / Atom feed
* Arrays and Access types...
@ 2001-10-26  4:46 Eric G. Miller
  2001-10-26  5:39 ` James Rogers
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Eric G. Miller @ 2001-10-26  4:46 UTC (permalink / 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>



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

end of thread, other threads:[~2001-10-27 18:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-26  4:46 Arrays and Access types Eric G. Miller
2001-10-26  5:39 ` 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

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