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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f0ba82308a594485 X-Google-Attributes: gid103376,public From: Laurent Guerby Subject: Re: Right of Optimize Eager Evaluation Away Date: 1999/11/28 Message-ID: <861z9afhgd.fsf@ppp-173-146.villette.club-internet.fr>#1/1 X-Deja-AN: 554172484 References: <863dtqfo26.fsf@ppp-173-146.villette.club-internet.fr> X-Trace: front3.grolier.fr 943823330 7382 195.36.173.146 (28 Nov 1999 21:08:50 GMT) Organization: Club-Internet (France) NNTP-Posting-Date: 28 Nov 1999 21:08:50 GMT Newsgroups: comp.lang.ada Date: 1999-11-28T21:08:50+00:00 List-Id: Robert A Duff writes: > Laurent Guerby writes: > > The question is: is a smart Ada 95 compiler allowed to generate code > > that looks like this: > > > > if C then > > X := Super_Expensive_Function_Call_1; > > else > > X := Super_Expensive_Function_Call_2; > > end if; > > > > that is to say, be lazy about its argument, and so might > > save execution time. > No. The function arguments may be evaluated in either order, so in case > of exception, the other one might not happen. But without exceptions, > both arguments will be evaluated. Is the potential raising of an exception the only language barrier here (since as you mention the compiler is free to swap calls defeating a class of side effects)? This seams easy to fix (via a pragma), if one is interested in keeping the functional aspect of the code instead of resorting to statements of course. > - Bob --LG