comp.lang.ada
 help / color / mirror / Atom feed
* ADA Max Array Size HELP!!!!
@ 1992-09-22 19:06 pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace
  0 siblings, 0 replies; 2+ messages in thread
From: pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace @ 1992-09-22 19:06 UTC (permalink / raw)


mgeorgy@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 amoun
t
: of memory the computer has, but how, is it measured by INTEGER'LAST, and if s
o
: 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
<wallace@cookie.enet.dec.com>

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

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

* Re: ADA Max Array Size HELP!!!!
@ 1992-09-23 19:36 Dave Marshall
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Marshall @ 1992-09-23 19:36 UTC (permalink / raw)


> 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
                                           dmarshal@stars.reston.unisys.com

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

end of thread, other threads:[~1992-09-23 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-09-22 19:06 ADA Max Array Size HELP!!!! pa.dec.com!nntpd2.cxo.dec.com!bonmot!wallace
  -- strict thread matches above, loose matches on Subject: below --
1992-09-23 19:36 Dave Marshall

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