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:19:41 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!falcon.america.net!newspump.monmouth.com!newspeer.monmouth.com!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 10:11:57 +0200 Organization: MIDA Systemutveckling AB Message-ID: <3AC2EE4D.56D61A58@mida.se> References: <3AC03CCE.70E3C2D5@mida.se> <87ae67qdrv.fsf@deneb.enyo.de> <87lmprow3a.fsf@deneb.enyo.de> <874rweoo2p.fsf@deneb.enyo.de> 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 985853533 24073 195.163.250.40 (29 Mar 2001 08:12:13 GMT) X-Complaints-To: abuse@algo.net NNTP-Posting-Date: 29 Mar 2001 08:12:13 GMT X-Mailer: Mozilla 4.6 [en] (WinNT; I) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6195 Date: 2001-03-29T08:12:13+00:00 List-Id: Ted Dennison wrote: %< > Let us assume there is a compiler X that allows any aribitrary routine to be > supplied which it will run during the compile phase, find the result, and store > that result value in a constant. There are two possible approaches that X can > take to support this capability. > > Approach 1 is that compiler X makes no attempt to verify that the supplied > routine is valid. In this case, it would be possible for the user to supply a > non-halting routine to the compiler (eg: an estimating integration routine that > has a bug where it never converges). Thus a compiler that takes approach 1 can > under some circumstances go into an infinte loop during compilation due to a bug > in user code, and it must be the user's responsiblily to prevent this, and to > detect the condition when it occurs (vs. a routine that just takes a long time) > and kill the compiler somehow. This must be accepted as normal operation of > compiler X(1). Yes, of course, but to me that's not a big deal. Further more it can be handled by for example limiting the execution time of the supplied function (better probably to limit its ability to loop though). > Approach 2 is that compiler X does not accept non-halting routines. However, > this means compiler X(2) is magic, since the halting problem has been proven to > be unsolvable in the general case. Whatever you do, don't tick off the developer > of X(2)! :-) Yes, I know. At least some of the logic courses I've taken is still accessable :) > I'd claim that most developers will not accept the responsibility of an X(1) > compiler, and X(2) is impossible. The only possible way out is to somehow put > restrictions on the routines that may be supplied to the compiler so that all > possilbe non-halting routines are disallowed. That pretty much means nothing > with a loop (except possibly a for loop) or a goto, or another subroutine call > (recursion is another type of loop, but this may be softened by building and > checking some kind of call tree at compile time instead). These restrictions > would allow some simple subroutines, but nothing complicated like a > pointer-based list search or an estimating integrator, which is the kind of > stuff the original poster wanted to use. As another poster noted and I state above, the non halting function problem may not be that severe, during development you just hit Control-C and investigate. In prduction batch build the compiler should be on a time limit anyway. I still feel that the benefits of haveing macro-like like capabilities that can use more or less the full power of Ada would be wery useful. -- 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