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-28 17:42:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!fr.usenet-edu.net!usenet-edu.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!europa.netcrusader.net!152.163.239.130!portc01.blue.aol.com!peerfeed.news.psi.net!filter.news.psi.net!reader.dist.news.psi.net!client!not-for-mail Message-ID: <3AC29167.3DF1@synquiry.com> From: Jon S Anthony X-Mailer: Mozilla 3.01 (X11; I; SunOS 5.6 sun4u) 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: Wed, 28 Mar 2001 20:35:35 -0500 NNTP-Posting-Host: 38.151.18.1 X-Trace: client 985829774 38.151.18.1 (Wed, 28 Mar 2001 20:36:14 EST) NNTP-Posting-Date: Wed, 28 Mar 2001 20:36:14 EST Xref: supernews.google.com comp.lang.ada:6182 Date: 2001-03-28T20:35:35-05: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. This sort of thing can be extremely useful - even if all you are doing is computing a "usual" value like you suggest (far more interesting stuff can be done as noted below...) > >I have hoped to get the time to either build a small preprocessor to do If you are in some sort of "tight" ("small" memory, i.e., < 8 meg or so) real time situation, you are going to have to resort to tricks/hacks like the one you use. If not, you should consider looking into Common Lisp for which this is a trivial example of a much broader capability - full compile time use of the language to compute anything, in particular code. > 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. Common Lisp is probably the best example, i.e., not a research toy or hack, but a highly optimized, fully capable and industrial strength language for serious applications. Compilation is typically extremely fast and resulting code typically in the 1.2 of C range. > 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 no. All you would need would be a compiler for the target and an emulator or interpreter for the host. /Jon -- Jon Anthony Synquiry Technologies, Ltd. Belmont, MA 02478, 617.484.3383 "Nightmares - Ha! The way my life's been going lately, Who'd notice?" -- Londo Mollari