comp.lang.ada
 help / color / mirror / Atom feed
From: Sami Evangelista <sami.evangelista@wanadoo.fr>
Subject: parameters evaluation
Date: Fri, 27 Sep 2002 16:55:45 +0200
Date: 2002-09-27T14:52:20+00:00	[thread overview]
Message-ID: <3D947171.2040909@wanadoo.fr> (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




             reply	other threads:[~2002-09-27 14:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-27 14:55 Sami Evangelista [this message]
2002-09-27 14:16 ` parameters evaluation Simon Wright
2002-09-27 15:14 ` Jean-Pierre Rosen
replies disabled

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