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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-05 07:43:14 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-out.visi.com!petbe.visi.com!news.octanews.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Thu, 05 Feb 2004 10:43:12 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: In-Out Parameters for functions References: <1075390647.405841@master.nyc.kbcfp.com> <1075405582.982776@master.nyc.kbcfp.com> <1075482385.142744@master.nyc.kbcfp.com> <1075732402.294581@master.nyc.kbcfp.com> <1075741279.952497@master.nyc.kbcfp.com> <16nu1099ekujjbpe9dqvs3noi9sdcfja6e@4ax.com> <1075817212.745748@master.nyc.kbcfp.com> <1075824683.769215@master.nyc.kbcfp.com> <1075851506.238480@master.nyc.kbcfp.com> <4020C947.81A6D703@0.0> <1075907239.138068@master.nyc.kbcfp.com> <402232E9.3EE15B4B@0.0> <1075987360.225622@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1075995793.145904@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@carrots.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1075995793 27852 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:5255 Date: 2004-02-05T10:43:12-05:00 List-Id: Robert I. Eachus wrote: > Hyman Rosen wrote: >> But you are now talking about finding an optimal implementation >> order for an expression involving more than one function call >> where the compiler has no access to the body of the functions. >> Do you really think that allowing the compiler to pick the order >> of the calls will significantly affect the efficiency? > > Of course it will. Consider for one example a Pure subprogram, say a > call to Sin or Log from a math package inside a loop. The pragma Pure > rules allow the compiler to hoist the call outside the loop, if the > parameter(s) are unchanged in successive calls. Sigh. When I said "access to the body" I meant that the compiler has no more information about what the function does than its declaration. Obviously if a function is declared Pure then its return value is not affected by order of execution, and the compiler can hoist away. Think about it - if you write s := Sin(x) + Cos(y) Ada requires that both arguments are evaluated, but doesn't specify the order. Yet, with a pragma Pure in place, Ada need not evaluate the operands each time in a loop, but can hoist the calculations out, as you say. Why would specifying the order change this?