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 06:45:20 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!hub.org!hub.org!newsfeed.mesh.ad.jp!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison Sender: usenet@www.newsranger.com References: <3AC03CCE.70E3C2D5@mida.se> Subject: Re: Compile time executed functions Message-ID: Date: Tue, 27 Mar 2001 14:39:28 GMT NNTP-Posting-Host: 127.0.0.1 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 985703968 127.0.0.1 (Tue, 27 Mar 2001 09:39:28 EST) NNTP-Posting-Date: Tue, 27 Mar 2001 09:39:28 EST Organization: http://www.newsranger.com Xref: supernews.google.com comp.lang.ada:6112 Date: 2001-03-27T14:39:28+00:00 List-Id: In article <3AC03CCE.70E3C2D5@mida.se>, Mats Karlssohn says... >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. > >Example (pleas, this is just an example, it hasn't been compiled): .. >- The constant is really a constant an should therefore be placed in >ROM. >- Therefore the function Generate_CRC_Table isn't needed in the output > at all and since it may be quite large and/or time consuming it would > be nice to do the job once, at compile time. .. >I must admit that I havn't researched enough to say that I can't get the >same effect using generice and/or other techniques in Ada. You can't. As near as I can tell, you are doing what you need to do in order to get the result you desire. >I have hoped to get the time to either build a small preprocessor to do >this kind of execution/substitution trick, or to add the same trick into >GNAT using some pragma(Compiler_Executed, func). Sorry to say, I don't >see that ammount of time in the near future. If you are talking about being able to run pretty much *any* code at compile time, no that can't be done with just a "trick". I don't know of any language in existance (but I suppose there probably is one somewhere) that will let you do that. It might be doable for a self-hosted system, but for a cross-compiled system (which I suspect is your situation, otherwise you wouldn't be worrying about making the result ROMable) I don't think it would be possible at all. The cross compiler would also have to include a full-fledged native compiler! --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com