comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: ??? Help!: how to do unconstraned arrays/records???
Date: 1998/11/05
Date: 1998-11-05T00:00:00+00:00	[thread overview]
Message-ID: <F1yvA7.E30.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 3641FDA2.812D683B@avionics2.robins.af.mil

al johnston (johnstona@avionics2.robins.af.mil) wrote:

: >are dangerous.  Since the exercise was to create a type for
: >heap allocation, it seemed OK to do it here.

: Taft,
 ^^ Tucker 

: actually that wasnt the exercise... although it is probably the way I
: misstated
: my original request that caused the confussion.... I dont really need the
: alloc-
: ation to be done on heap... but rather that the allocateion of memory to be
: "sized" at run time rather than at compile time.  at run time i get the
: numhosts
: and numnodes and size the array at that time....  now that may dictate
: that the memory be allocated on the heap rather than otherwise... I dont
: know... i sure dont understand the details of ada...  But the only reason
: we are using pointers and "new" is because I couldnt convins ada's to
: handle my requirmens for a "unconstraned" data struture....

If that is all you needed to do, you could probably leave the structures 
exactly as they were originally, and just make the "constants"
Number_Of_Hosts.. and Number_Of_Nodes... be initialized at elaboration
time by calling a function.  E.g.:

   Number_Of_Hosts : constant Natural := Parameters.Get_Host_Count(...);
   Number_Of_Nodes : constant Natural := Parameters.Get_Node_Count(...);

and then go on to use these "constants" in your data
structure definitions as you were doing.  The only problem with
this approach is that doing significant work at elaboration
time can be tricky due to elaboration order problems -- you
might end up with Program_Error's being raised.

In the above example, you would certainly want a 
"pragma Elaborate(Parameters);" after the "with Parameters;" clause
on the package with this host/node data structure, to minimize the
chance of a Program_Error due to an elaboration order problem.

: anyway, your sollution is fine for my app...  and I have not seen a better
: one suggested..

Glad to hear it...

: thanks again....

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




  reply	other threads:[~1998-11-05  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-04  0:00 ??? Help!: how to do unconstraned arrays/records??? al johnston
1998-11-04  0:00 ` Albert S. Johnston
1998-11-05  0:00   ` dewarr
1998-11-05  0:00     ` al johnston
1998-11-05  0:00       ` dewar
1998-11-05  0:00       ` Stephen Leake
1998-11-05  0:00 ` Tucker Taft
1998-11-05  0:00   ` Tucker Taft
1998-11-05  0:00     ` Mats Weber
1998-11-05  0:00       ` Tucker Taft
1998-11-05  0:00         ` al johnston
1998-11-05  0:00           ` Tucker Taft [this message]
1998-11-06  0:00             ` Mats Weber
1998-11-06  0:00               ` Tucker Taft
1998-11-05  0:00   ` Tucker Taft
1998-11-05  0:00     ` al johnston
replies disabled

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