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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5b3aa4bc9027f04e,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!d36g2000prf.googlegroups.com!not-for-mail From: belteshazzar Newsgroups: comp.lang.ada Subject: Unconstrained Arrays Date: Mon, 16 Mar 2009 17:59:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1a8008fb-c840-45bc-824c-d10eec9fe569@d36g2000prf.googlegroups.com> NNTP-Posting-Host: 203.36.107.146 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1237251575 7292 127.0.0.1 (17 Mar 2009 00:59:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 17 Mar 2009 00:59:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d36g2000prf.googlegroups.com; posting-host=203.36.107.146; posting-account=SuaatgoAAADZMrKGiLdPOjCBBS4KZzVT User-Agent: G2/1.0 X-HTTP-Via: 1.1 SRV021 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5121 Date: 2009-03-16T17:59:35-07:00 List-Id: 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. We have now noticed that because of the size of our arrays that the array intialisation is causing significant performance issues. Thus, we need a new way of handling our arrays. The best option seems to be to turn the functions that take arrays into generic functions and instantiate them on the fly according to the required size. Does anyone know if there are performance issues with dynamically creating instantiations of generic functions all over teh place? 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. Has anyone come across these sorts of issues? I'm curious as to the solution that others have found, and why Ada seems to handle unconstrained arrays differently to unconstrained arrays inside a record.