TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date: Sat, 23 Dec 2000 15:20:35 -0800
Reply-To: Tom Moran <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Organization: Decision Aids
From: Tom Moran <[log in to unmask]>
Parts/Attachments: text/plain (24 lines)
> I'm wondering how to set the size of an unconstrained array.
  Any particular array is constrained.  You can write, for instance, a
sort routine that sorts an unconstrained array, but any particular call
will pass it a particular, constrained, array.  So the declaration of an
object of unconstrained array type (a String, for instance) will give a
specific size.

> I'm wondering if there is any way to modify the size of an
> array during run-time
  You could allocate an array on the heap, then if it needs to be bigger
you can allocate a new, larger, array, copy the contents of the old
array, then deallocate the old one.

> I really don't want to just make a
> large array, and use that, and hope that all my data will
> always fit into this array.
  That may in fact be the best way to go, depending on your OS's virtual
memory implementation.  If a giant array is made of real memory pages
that only take up RAM when actual data is written into them, then if you
only use the first part, only a few pages of real memory will actually
be allocated.  If you add data beyond that, the OS will allocate more
pages of real memory.  But the high-index parts you never actually use
will never actually be allocated by the OS.