Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADA Max Array Size HELP!!!!

70 views
Skip to first unread message

Richard Wallace

unread,
Sep 22, 1992, 3:06:32 PM9/22/92
to
mge...@vmsclst1.sc.csupomona.edu writes:
: I am having trouble figuring out how array sizes are determined, or should I
: say what the largest size possible if??? I know that this involves the amount
: of memory the computer has, but how, is it measured by INTEGER'LAST, and if so
: how does this figure into a multi-dimentional Array, or Matrix.
:
: Basicaly this is what I am trying to do:
: type TEST is array (1..512, 1..512) of TYPE;
: but it won't let me, why not???
:
: Thanx,
: Matt Georgy

Matt,
Given the code fragment above, the TYPE conflicts with the
reserved word "type" in the Ada'83 LRM.
To try and answer what I think is your real question (my rewrite),
"How much memory will my declaration consume?"

for example:

with TEXT_IO;
procedure FOO is

package MY_INT_IO is new TEXT_IO.INTEGER_IO(INTEGER); use MY_INT_IO;

type TEST is array(1..512,1..512) of INTEGER;

BAR : TEST;

begin

MY_INT_IO.PUT( INTEGER ( BAR'size / 8) ); TEXT_IO.NEW_LINE;

end FOO;

When run, the answer of 1048576 is given (for a VAX/VMS) system because
an INTEGER type is 4 bytes and a byte on this machine is 8 bits.

To figure out the storage requirements look in package SYSTEM for your
run-time system. This will list the information you need. For types of
FLOAT, "digits" and record types (exception of variants) all you need do
is figure out your systems storage elements and then do simple math to
construct the storage space requied. Remember that storage is usually not
assigned until an object of that type is declared.

For variant records, this is a *rule of thumb* and not an absolute, the
largest variant is the unit storage size for that record. Knowing that
size, then the rest is as above.

Hope this helps!

Richard Wallace
Digital Equipment Corporation
301 Rockrimmon Blvd. South
CXO2-1/7A
Colorado Springs, CO 80919-2398
(719)548-2792
<wal...@cookie.enet.dec.com>

"The opinions expressed are my own, Unlce Ken or Uncle Bob
may, or may not, agree with me.

Dave Marshall

unread,
Sep 23, 1992, 3:36:09 PM9/23/92
to
> with TEXT_IO;
> procedure FOO is
>
> package MY_INT_IO is new TEXT_IO.INTEGER_IO(INTEGER); use MY_INT_IO;

The above instantiation is unnecessary. See below.


>
> type TEST is array(1..512,1..512) of INTEGER;
>
> BAR : TEST;
>
> begin
>
> MY_INT_IO.PUT( INTEGER ( BAR'size / 8) ); TEXT_IO.NEW_LINE;

^^^^^^^

This cast is unnecessary, BTW. 'SIZE is of type universal-integer, which
any compiler will gladly convert to whatever integer type you need it for.

Try instead:

TEXT_IO.PUT_LINE( INTEGER'IMAGE ( BAR'SIZE / 8));


>
> end FOO;
>
> When run, the answer of 1048576 is given (for a VAX/VMS) system because
> an INTEGER type is 4 bytes and a byte on this machine is 8 bits.
>

Same result on a Sun.

Here's a question for the Verdix gurus:

When I try the above program, I get a storage error exception. When I modify
it slightly to dynamically allocate the array object, no problem. What do
I need to do to get the above program without resorting to access types?
--
Dave Marshall
dmar...@stars.reston.unisys.com

0 new messages