子程序声明部分求值顺序 Ada
subprogram declarative section order of evaluation Ada
在 Ada 中子程序的声明部分,变量赋值的计算顺序是它们声明的顺序吗?例如,如果我写
procedure Foo() is
I: Integer := 4;
J: Integer := I * 2;
begin
--do stuff
end Foo;
我可以肯定地说 I
总是会在 J
之前计算吗?
在我看来,根据 ARM 3.11(7):
,声明性项目确实是按顺序求值的
The elaboration of a declarative_part consists of the elaboration of the declarative_items, if any, in the order in which they are given in the declarative_part.
已编辑: ARM 来源
在 Ada 中子程序的声明部分,变量赋值的计算顺序是它们声明的顺序吗?例如,如果我写
procedure Foo() is
I: Integer := 4;
J: Integer := I * 2;
begin
--do stuff
end Foo;
我可以肯定地说 I
总是会在 J
之前计算吗?
在我看来,根据 ARM 3.11(7):
,声明性项目确实是按顺序求值的The elaboration of a declarative_part consists of the elaboration of the declarative_items, if any, in the order in which they are given in the declarative_part.
已编辑: ARM 来源