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-04-02 06:42:07 PST Newsgroups: comp.lang.ada Path: supernews.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!europa.netcrusader.net!208.184.7.66!newsfeed.skycache.com!Cidera!news-reader.ntrnet.net!uunet!ash.uu.net!world!bobduff From: Robert A Duff Subject: Re: Compile time executed functions Sender: bobduff@world.std.com (Robert A Duff) Message-ID: Date: Mon, 2 Apr 2001 13:40:22 GMT 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> <3AC6ED5F.9F2F51A5@free.fr> <3AC84628.D8B70C7C@free.fr> Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.3/Emacs 19.34 Xref: supernews.google.com comp.lang.ada:6337 Date: 2001-04-02T13:40:22+00:00 List-Id: "Ken Garlington" writes: > Which is exactly the point - there doesn't seem to be a true "compile time" > function with respect to either language, only optimization techniques that > are applied to various degree in *instances* of the language. Well, I wouldn't call the C++ template case an "optimization". To me, and optimization is when the compiler goes to extra trouble in the hopes of generating more efficient code. "Extra trouble" = more trouble than the simplest compilation technique anybody can imagine. If a compiler evaluates an Ada function at compile time, that's clearly an optimization. But a C++ compiler would have to go to extra trouble *not* to evaluate templates at compile time -- so I don't call it an optimization to evaluate them at compile time. In fact, I'll bet that 100% of all C++ compilers that now exist, or that ever exist, are capable of evaluating the example (the factorial template someone posted) at compile time. >... Note that it > could be possible for a language to define required optimizations -- Erlang, > for example, appears to do so with tail recursion -- but asking for Ada to > provide the "same guarantees" as C++ in this area is vacuously true, AFAIK. Formally speaking, that's true. >...If your program was > depending upon not being surprised, this would be a Bad Thing -- thus, it's > always a good idea IMHO not to depend upon such "sanity". It's unavoidable. All programs depend on various "sanity" aspects of compilers -- aspects that are not formally defined in the language definition. - Bob