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 08:46:38 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!newsfeed.berkeley.edu!ucberkeley!hammer.uoregon.edu!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.frmt1.sfba.home.com.POSTED!not-for-mail Message-ID: <3AC044D5.75D8C751@home.com> From: Mark Biggar X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Compile time executed functions References: <3AC03CCE.70E3C2D5@mida.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 27 Mar 2001 16:40:59 GMT NNTP-Posting-Host: 65.3.211.243 X-Complaints-To: abuse@home.net X-Trace: news1.frmt1.sfba.home.com 985711259 65.3.211.243 (Tue, 27 Mar 2001 08:40:59 PST) NNTP-Posting-Date: Tue, 27 Mar 2001 08:40:59 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: supernews.google.com comp.lang.ada:6124 Date: 2001-03-27T16:40:59+00:00 List-Id: Ted Dennison wrote: > > 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. > >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! Actually almost any compiled langauge "supports" this using a "trick". You can always write separate standalone programs that generate source code to be compiled. It's trivial to set up your make file or equivalent to support this. The generated program doesn't even have to be the same lanaguage if you don't have a self-hosted backend for Ada. Even using a scripting langauge like Perl or Python would do. So, his best bet is to write a small program that generates the Ada source code for the constant table in it's own package. Not only does this solve his problem, but is much easier to debug problems with the table as the result is human readable and verifiable. -- Mark Biggar mark.a.biggar@home.com