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 05:46:02 PST Newsgroups: comp.lang.ada Path: supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!howland.erols.net!cpk-news-hub1.bbnplanet.com!chcgil2-snf1.gtei.net!news.gtei.net!newspump.sol.net!nntp.msen.com!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 12:42:57 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:6330 Date: 2001-04-02T12:42:57+00:00 List-Id: Jean-Marc Bourguet writes: > My question? Me comparing C++ and Ada? I think you are confusing me > with somebody else. I came into this thread when you asked for an > example of using template in C++ for computing things at compile time to > give you one. Then you asked for a formal guarantee that it was > computed at compile time. The level at which the C++ standard describe > semantic make it impossible to have such guarantee. Do you have a > formal guarantee that an Ada compiler does not generate a function to > calculate the 10! when you use the litteral 3628800? I don't think so > and there is no such guarantee for C++. What the C++ standard does is > constraint the expression to be a constant integer expression and allows > the defined named and such expressions to be used in place like case > labels, array sizes and template parameters where no C++ programmer > would expect the expression be evaluated at run-time, where no sane C++ > compiler would evaluate the expression at run-time. Right. In fact, a C++ compiler would have to go to some extra trouble to evaluate these sorts of things at run time, so it's safe to say that it doesn't. > Some seems to think that the biggest difference between Ada generic and > C++ template is the fact that the templates are instanciated > automatically or that they are constrained by use. My point of view is > that these differences are syntaxic differences and do not modify > significantly the expressing power. I think that the ability to > specialize template is a point where the C++ templates are more > powerfull than the Ada generics. Also, Ada generics can't be recursive. - Bob