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,f188b1cd9c1f24dc X-Google-Attributes: gid103376,public From: Peter Amey Subject: Re: Parameter evaluation order Date: 1998/04/09 Message-ID: <352D54AD.7B68@praxis-cs.co.uk>#1/1 X-Deja-AN: 342445981 Content-Transfer-Encoding: 7bit References: <6g9d2o$tfg$1@nnrp1.dejanews.com> Content-Type: text/plain; charset=us-ascii Organization: Praxis Critical Systems Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-04-09T00:00:00+00:00 List-Id: I have been trying to resist the temptation but... Robert A Duff wrote: > > In article , Robert Dewar wrote: > >This is misleading. This has nothing to do with optimization, The order > >of parameter evaluation is non-deterministic, the program worked exactly > >as it should, it was just that the programmer had some incorrect expectation > >based on a misunderstanding of Ada semantics. > [snip] > > I'm not even convinced the tradeoff is worthwhile. That is, perhaps it > *is* a stupid rule, despite the fact that it might make some programs > run faster. I don't like nondeterministic semantics. > ...if you really don't like non-deterministic semantics you need to program in SPARK. The originally-posted code would not malfunction if it were in SPARK because the function calls used as actual parameters would not have side-effects and so the evaluation order would not matter. SPARK also provides complete protection against erroneous behaviour arising from parameter passing mechanisms, elaboration order etc. Incidently, you don't need to use functions to get the effect described, consider: procedure Init2(X, Y : out integer) is begin X := 0; Y := 1; end Init2; What is the meaning of Init2(A, A); ? regards Peter --------------------------------------------------------------------------- __ Peter Amey, Product Manager ) Praxis Critical Systems Ltd / 20, Manvers Street, Bath, BA1 1PX / 0 Tel: +44 (0)1225 466991 (_/ Fax: +44 (0)1225 469006 http://www.praxis-cs.co.uk/ --------------------------------------------------------------------------