Last active
May 25, 2016 06:12
-
-
Save kimtg/26353170510ebc25a343685c37abe150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO, Ada.Integer_Text_IO; | |
use Ada.text_IO; | |
procedure Eval_Order is | |
function Minus(A, B : Integer) return Integer is (A - B); | |
function Get return Integer is | |
R : Integer; | |
begin | |
Ada.Integer_Text_IO.Get(R); | |
return R; | |
end; | |
begin | |
-- Arguments are evaluated from right to left. | |
Put_Line(Integer'Image(Minus(Get, Get))); | |
end Eval_Order; |
Author
kimtg
commented
May 18, 2016
•
ARM 6.4(8/2):
"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). ... These evaluations are done in an arbitrary order."
(http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-6-4.html)
Your version of GNAT used right-to-left in this case. It might use a different order for a different case. Even if it always uses right-to-left, another compiler, and even another version of GNAT, might use a different order.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment