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=2.0 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d855403bbf39dab1,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.222.71 with SMTP id qk7mr6958737pbc.1.1328353216324; Sat, 04 Feb 2012 03:00:16 -0800 (PST) Path: lh20ni259229pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: can one create an array of a size determined by a constant value of a function? Date: Sat, 04 Feb 2012 05:00:11 -0600 Organization: Aioe.org NNTP Server Message-ID: Reply-To: nma@12000.org NNTP-Posting-Host: S73IhUdXviTOBMM4YZU9dA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-02-04T05:00:11-06:00 List-Id: Quick question for the experts: I was looking at c++11 standard, where it show how one can allocate an array of some size. The size is determined by a function call. This is done at compile time though where the compiler can determine the result of the function, like this: http://en.wikipedia.org/wiki/C%2B%2B11#cite_note-2 "constexpr int get_five() {return 5;} int some_value[get_five() + 7]; // Create an array of 12 integers. Legal C++11 This allows the compiler to understand, and verify, that get_five is a compile-time constant. " constexpr is new and was added in c++11 Is it possible to do something like this in Ada? I am not sure now how useful or common such a feature would be actually, but was just wondering how it will look in Ada. thanks, --Nasser