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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,571930b4ff0bc1ee X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-29 00:03:55 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!news.tele.dk!194.213.69.151!news.algonet.se!algonet!pepsi.tninet.se!not-for-mail From: Mats Karlssohn Newsgroups: comp.lang.ada Subject: Re: Compile time executed functions Date: Thu, 29 Mar 2001 09:58:15 +0200 Organization: MIDA Systemutveckling AB Message-ID: <3AC2EB17.33AAEC0A@mida.se> References: <3AC03CCE.70E3C2D5@mida.se> <3AC18DD1.EF25CE42@mida.se> <5mzw6.415$1H6.72722473@newssvr16.news.prodigy.com> NNTP-Posting-Host: sdu40-250.ppp.algonet.se Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: cubacola.tninet.se 985852710 22869 195.163.250.40 (29 Mar 2001 07:58:30 GMT) X-Complaints-To: abuse@algo.net NNTP-Posting-Date: 29 Mar 2001 07:58:30 GMT X-Mailer: Mozilla 4.6 [en] (WinNT; I) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6193 Date: 2001-03-29T07:58:30+00:00 List-Id: Ken Garlington wrote: %< > : The other issue is that I feel that within Ada's expressive powers > : it would be useful to have _some_ of the possibilities that is > : availible when using C++ templates and/or C preprocessor macros. > : (Please, no flames on the two 'bad words' above!) > > Is this a different subject than resolving complex functions as simple ROM > constants? I'm having trouble seeing how a complex function written as a > macro consistently ends up as a constant... I'll try to explain a little more. But first, forget about the RAM/ROM issue, it was a mistake to include that in the original post. Say I want to create a table of data. The data is constant and must not change during the programs lifetime. Further more, the data is quite time consuming to calculate. In C++ (bad word again :) I can (with some effort) write a template that does all the calculations in the compiler at compile time. In Ada, my experience is that I end up with something like: package BlaBlah is -- declarations needed MyLookupData : constant LookupTable := GenerateTable(parameter); end BlahBlah; GenerateTable will be called at package elaboration time, and therefore consume time on the target. Moreover, the GenerateTable code is not used by anything else but is included into the loadmodule anyway. Now IF I haf a pragma that tagged GenerateTable as a 'compiler executed function' it would allow the compiler to compile a native version of Generatetable, execute it and use the result as a literal when compiling package BlahBlah. Furthermore the compiler would know that GenerateTable isn't needed on the target and thus eliminate it's code. As I noted in the original post, this can be (and is today) solved by manually putting GenerateTable into its own program and the pasting the output into the source of package BlahBlah. This has caused management problems and I expect it to continue to do so. Am I plain stupid since I worry about when what's included in my output and when time is consumed ? -- Mats Karlssohn, developer mailto:mats@mida.se Mida Systemutveckling AB http://www.mida.se Box 64, S-732 22 ARBOGA, SWEDEN Phone: +46-(0)589-89808 Fax: +46-(0)589-89809