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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Everything You Know Is Wrong Date: Tue, 29 Dec 2015 16:05:09 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1451426709 6835 24.196.82.226 (29 Dec 2015 22:05:09 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 29 Dec 2015 22:05:09 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:28930 Date: 2015-12-29T16:05:09-06:00 List-Id: "G.B." wrote in message news:n5uh6q$chh$1@dont-email.me... > On 29.12.15 18:36, Dmitry A. Kazakov wrote: ... >> No, because initialization of T may have side effects. > > I assume you meant Yes, impossible. But, > if F1 and F2 are from a Pure package, is the compiler allowed to > ignore side effects because the programmer specified Pure? I think > that follows. Ada does allow compilers to ignore side-effects for Pure functions, but only for successive calls to the same function with the same parameters. Which is not enough for your example. And you're right, it *should* follow, but Pure is broken. For parallel execution, we need something stronger - and it's in the hopper today. (Algebraic optimizations also need something stronger.) [Pure, for instance, allows dereferencing of pointers, which could change by some other path. And making it apply to an entire package screws up organization, since most packages have a bunch of pure functions and many other, non-pure operations.] One of the reasons Ada 2012 has expression functions is that if the compiler can see the entire function definition, it can then do these sorts of optimizations. (But that's a weak solution for many reasons.) Randy.