* Re: parameters evaluation
2002-09-27 14:55 parameters evaluation Sami Evangelista
@ 2002-09-27 14:16 ` Simon Wright
2002-09-27 15:14 ` Jean-Pierre Rosen
1 sibling, 0 replies; 3+ messages in thread
From: Simon Wright @ 2002-09-27 14:16 UTC (permalink / raw)
Sami Evangelista <sami.evangelista@wanadoo.fr> writes:
> 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
[...]
> the output should "logically" be
> F
> G
> H
>
> but it is
> G
> F
> H
I think you are wrong to say that your compiler is acting "wrong" or
not "logically".
See ARM 6.4(10) at http://www.adaic.org/standards/95lrm/html/RM-6-4.html -
For the execution of a subprogram call, the name or prefix of the
call is evaluated, and each parameter_association is evaluated (see
6.4.1). If a default_expression is used, an implicit
parameter_association is assumed for this rule. These evaluations
are done in an arbitrary order.
^ permalink raw reply [flat|nested] 3+ messages in thread
* 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
* Re: parameters evaluation
2002-09-27 14:55 parameters evaluation Sami Evangelista
2002-09-27 14:16 ` Simon Wright
@ 2002-09-27 15:14 ` Jean-Pierre Rosen
1 sibling, 0 replies; 3+ messages in thread
From: Jean-Pierre Rosen @ 2002-09-27 15:14 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
"Sami Evangelista" <sami.evangelista@wanadoo.fr> a �crit dans le message
news: 3D947171.2040909@wanadoo.fr...
> 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
>
[snip]
The order of evaluation of parameters is not defined by the language. The
output of the program is correct.
--
---------------------------------------------------------
J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
^ 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