comp.lang.ada
 help / color / mirror / Atom feed
* parameters evaluation
@ 2002-09-27 14:55 Sami Evangelista
  2002-09-27 14:16 ` Simon Wright
  2002-09-27 15:14 ` Jean-Pierre Rosen
  0 siblings, 2 replies; 3+ messages in thread
From: Sami Evangelista @ 2002-09-27 14:55 UTC (permalink / raw)


hello all

i have noticed a strange thing about expressions evaluations during a 
procedure or function call. it appears that the parameters are evaluated 
in the "wrong" order. Try this

-------------------------------------------------------------
with ADA.TEXT_IO;
use ADA.TEXT_IO;

procedure Proc is
    function F return Boolean is begin Put_Line("F"); return True; end;
    function G return Boolean is begin Put_Line("G"); return True; end;
    function H(B1, B2 : in Boolean) return Boolean is
    begin
       put_Line("H");
       return True;
    end;

begin
    if H(F, G) then null; end if;
end;
-------------------------------------------------------------

the output should "logically" be
F
G
H

but it is
G
F
H

so be careful if your functions change global variables or have others 
effects which is by the way not very clean.

Sami Evangelista




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-27 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-27 14:55 parameters evaluation Sami Evangelista
2002-09-27 14:16 ` Simon Wright
2002-09-27 15:14 ` Jean-Pierre Rosen

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