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-27 23:44:33 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!falcon.america.net!sunqbc.risq.qc.ca!news.maxwell.syr.edu!newsfeed1.uni2.dk!news.algonet.se!algonet!pepsi.tninet.se!not-for-mail From: Mats Karlssohn Newsgroups: comp.lang.ada Subject: Re: Compile time executed functions Date: Wed, 28 Mar 2001 09:29:20 +0200 Organization: MIDA Systemutveckling AB Message-ID: <3AC192D0.B1E48088@mida.se> References: <3AC03CCE.70E3C2D5@mida.se> NNTP-Posting-Host: sdu184-72.ppp.algonet.se Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: zingo.tninet.se 985765045 17383 195.163.72.184 (28 Mar 2001 07:37:25 GMT) X-Complaints-To: abuse@algo.net NNTP-Posting-Date: 28 Mar 2001 07:37:25 GMT X-Mailer: Mozilla 4.6 [en] (WinNT; I) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6151 Date: 2001-03-28T07:37:25+00:00 List-Id: Robert A Duff wrote: > > Mats Karlssohn writes: > > > Sometimes, especially when doing embedded programming, I feel a great > > need to execute a function to get literal initialization a constant. > > That is I'd like to have the compiler to execute a function for me (at > > compiletime!) and use the return of that function to initialize the > > constant. > > If you inline the function, you are likely to get what you want, > depending on how good the compiler's support for inlining is. OK, for the project at hand I don't have a choise for the compiler, but I'll put inlining support on my compiler checklist for future projects. > > I realize that a lot of limitations must be put on the > > Generate_CRC_Table function, but, have something along these lines been > > considered by the language designers. > > I don't think it's really a language design issue. The language doesn't > talk about how clever the compiler is about doing things at compile > time, nor about what goes in ROM vs RAM. I agree on the location issue (RAM vs. ROM), but the control over how and when the code is executed is already a language issue I think. We already have generics in the language wich controls how code should be generated. We also have pragma Inline and representation pragmas that controls the layout of code and data. So why couldn't we also have pragma(s) to _hint_ to the compiler that this piece of code is only used for initializing constants and is therefore NOT needed in the runtime image if the compiler executes it. And, yes, I realize that the analysis of the code may be to expensive and/or the tradeoffs that have to be made may cause all this to be unusable. -- 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