comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Amey <pna@praxis-cs.co.uk>
Subject: Re: Parameter evaluation order
Date: 1998/04/09
Date: 1998-04-09T00:00:00+00:00	[thread overview]
Message-ID: <352D54AD.7B68@praxis-cs.co.uk> (raw)
In-Reply-To: Er5Ir9.5Ip@world.std.com


I have been trying to resist the temptation but...

Robert A Duff wrote:
> 
> In article <dewar.892128071@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> 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/
 --------------------------------------------------------------------------




  parent reply	other threads:[~1998-04-09  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-05  0:00 Parameter evaluation order Mark.Rutten
1998-04-05  0:00 ` Matthew Heaney
1998-04-07  0:00   ` Don Harrison
1998-04-09  0:00   ` Simon Wright
1998-04-10  0:00     ` Matthew Heaney
1998-04-10  0:00       ` Simon Wright
1998-04-11  0:00         ` Robert Dewar
1998-04-06  0:00 ` William D. Ghrist
1998-04-06  0:00 ` Corey Ashford
1998-04-08  0:00 ` Glenden Lee
1998-04-09  0:00   ` Robert Dewar
     [not found]     ` <Er5Ir9.5Ip@world.std.com>
1998-04-09  0:00       ` Peter Amey [this message]
1998-04-09  0:00       ` Tucker Taft
1998-04-16  0:00         ` Nick Roberts
1998-04-17  0:00           ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox