From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,INVALID_MSGID, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3c37d6ac44550e08 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: ??? Help!: how to do unconstraned arrays/records??? Date: 1998/11/05 Message-ID: #1/1 X-Deja-AN: 408783345 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <3641FDA2.812D683B@avionics2.robins.af.mil> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-11-05T00:00:00+00:00 List-Id: 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