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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5b3aa4bc9027f04e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!wns14feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Unconstrained Arrays References: <1a8008fb-c840-45bc-824c-d10eec9fe569@d36g2000prf.googlegroups.com> In-Reply-To: <1a8008fb-c840-45bc-824c-d10eec9fe569@d36g2000prf.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 173.16.158.68 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1237254543 173.16.158.68 (Tue, 17 Mar 2009 01:49:03 GMT) NNTP-Posting-Date: Tue, 17 Mar 2009 01:49:03 GMT Organization: AT&T ASP.att.net Date: Tue, 17 Mar 2009 01:49:03 GMT Xref: g2news2.google.com comp.lang.ada:5122 Date: 2009-03-17T01:49:03+00:00 List-Id: belteshazzar wrote: > I have a program that uses a lot of different sized arrays and passed > into math functions. So I'm using an unconstrained array type. The > problem that I have is that I'm not allowed to use "new" this means > that I have to use pools (which I can't because to intantiate a pool I > have to constrain the array type) or allocated the arrays on the > stack. Allocating the arrays on the stack is fine, BUT it means that i > have to use array initializers so that they remain unconstrained > rather than becoming an anonomous contrained type that can no longer > be passed to my math functions. I'm not clear what you're talking about. You can pass a constrained subtype to a subprogram that takes a parameter of an unconstrained array type. For example, String is an unconstrained array type. If we have function F (S : in String) return Natural; V : String (1 .. 10); C : Natural; then it's perfectly legal to call F with V as its actual parameter: C := F (S); > Also, and the main point of my post, I've found that I can place the > unconstrained array inside a record with a distriminant and this seems > to solve all our problems. We don't have to use array initialisers and > we can get pointers to aliased objects that can be easily passed to > the math functions. Here is your problem. There should be no reason to pass explicit pointers to these functions. Your best solution is to rewrite or change your library. -- Jeff Carter "Drown in a vat of whiskey. Death, where is thy sting?" Never Give a Sucker an Even Break 106