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=0.6 required=5.0 tests=BAYES_00,FROM_WORDY autolearn=no 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-31 11:32:21 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!news.stealth.net!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.com!newsmst01!postmaster.news.prodigy.com!newssvr16.news.prodigy.com.POSTED!not-for-mail From: "Ken Garlington" Newsgroups: comp.lang.ada References: <3AC03CCE.70E3C2D5@mida.se> <3AC18DD1.EF25CE42@mida.se> <5mzw6.415$1H6.72722473@newssvr16.news.prodigy.com> <3AC2EB17.33AAEC0A@mida.se> <3AC46252.B7E54EA6@free.fr> <3AC4B7F9.7C73455A@free.fr> Subject: Re: Compile time executed functions Organization: ex-FlashNet, now Prodigy X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: NNTP-Posting-Host: 65.65.210.62 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr16.news.prodigy.com 986067033 6207069 65.65.210.62 (Sat, 31 Mar 2001 14:30:33 EST) NNTP-Posting-Date: Sat, 31 Mar 2001 14:30:33 EST Date: Sat, 31 Mar 2001 19:30:33 GMT Xref: supernews.google.com comp.lang.ada:6294 Date: 2001-03-31T19:30:33+00:00 List-Id: "Jean-Marc Bourguet" wrote in message news:3AC4B7F9.7C73455A@free.fr... : Ken Garlington wrote: : > : > "Jean-Marc Bourguet" wrote in message : > news:3AC46252.B7E54EA6@free.fr... : > : Ken Garlington wrote: : > : : > : > Could you post an example of such a template, and what in the C++ : > standard : > : > you rely upon to guarantee compile-time calculations? : > : : > : First feature, things like : > : enum { foo = x+y*z; } : > : are valid as long as x, y and z value are known at compile time and have : > : to be evaluated at compile time. : > : > Isn't this usually resolvable as a constant by most Ada compilers? At least : > the ones I know will usually do so. : : It is quite difficult to come with the equivalent in Ada. One is : foo : constant = x+y*z; : is indeed resolvable by most Ada compiler. : : > More to the point, does the C++ standard _require_ that foo not generate any : > assembly instructions to be executed at run-time? If so, what does it say? : : I've not checked what the standard says precisely. The enum values are : a compile time constant. They may be used in context like case label : which are to be fixed at compile time. This : : enum { a = 2, b = 3, c = 4, d = 7 }; : enum { foo = a+b*c }; : enum { bar = a*d }; : : void f() { : int foobar; : switch(foobar) { : case foo: : break; : case bar: : break; : } : } : : is required to produce a diagnostic as foo and bar have the same value. Same with Ada, as far as I know. These examples are all in terms of "the value has to be calculated as a scalar before it is used." This is *not* the same as saying "no code is generated at run-time".