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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,627a173c3309b242 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!nntp.giganews.com.MISMATCH!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 19 May 2004 16:16:33 -0500 Date: Wed, 19 May 2004 17:16:32 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Allocation of local constant arrays References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-DSfl+np2lVLaU7M6NPHhHmG1CcypHoq9DvtR3eeibW/ww+9FoHY0JRFsptE85QuiiK2FmkRBito1rh6!gTlLuiHR+UbuSU1gJf8n6r6vxll8BmH9tmUa41zL/cPYbxiD1J66ZyTuBtS/pQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: controlnews3.google.com comp.lang.ada:697 Date: 2004-05-19T17:16:32-04:00 List-Id: Davide wrote: > Hi, > > suppose to have a constant array declared inside a procedure. Suppose to > perform, inside that procedure, a loop in which the elements of the constant > array are accessed sequentially until some condition become true. > My question (i know it's a newbie question...): is the local constant array > copied into the stack each time the procedure is called or it is allocated > once and for all in some part of the memory? I'm using AdaMulti compiler. Some compilers can store such an array in the data segment. But if you care, and copying is an issue, put the array in a library level package. One of the most powerful optimization "tricks" in Ada is that you can put data in in structures inside library packages that would have to be allocate on the heap as in C, or nested inside a procedure or function. It is sometimes tricky to do all this before the main program executes, but it can be done. And it is great during debugging of mathematical packages to be able to read the tables from a file, then compile them into the final package when debugging is done. A good example is the inverse normal function. The best approach is to use different (approximation) algorithms for different parts of the function. It is nice to be able to test the various cut-points and interpolation constants without recompiling, then put everything as constants in the package body. -- Robert I. Eachus "The terrorists rejoice in the killing of the innocent, and have promised similar violence against Americans, against all free peoples, and against any Muslims who reject their ideology of murder. Their barbarism cannot be appeased, and their hatred cannot be satisfied. There's only one way to deal with terror: We must confront the enemy and stay on the offensive until these killers are defeated." -- George W. Bush