艾达。为什么 <<procedurename.all>> 需要从指针调用过程?

Ada. Why is <<procedurename.all>> required to call a procedure from a pointer?

我对 Ada 很陌生,我想知道为什么我必须写 Acc.all 或 d.all 来通过指针调用过程。我认为 .all 主要用于记录,因为这样您就可以将 .all 记录值设置为等于其他记录值。同时我想知道为什么我在调用函数时不需要这样做。这是我的代码供参考。请忘记 AnimalPKG.Animals(Total, 3,2,1),因为我只是在练习如何导入包。

    with AnimalPKG, Ada.Text_IO, Ada.Integer_Text_IO; 
    use Ada.Text_IO, Ada.Integer_Text_IO; 

    procedure Main is

       procedure thisisaccess is
          begin
          Put("thisisaccess"); 

          end thisisaccess;

       Type accessprocedure is access procedure;

       procedure passinfunction(d : accessprocedure) is 
          begin
         d.all; 
       end passinfunction; 

       function times5(a : Integer) return Integer is 
          begin
          return a*5; 
       end times5; 

       Type times5access is access function(x : Integer) return Integer; 

       B : times5access := times5'Access; 

        Acc : accessprocedure;
       Acc2 : accessprocedure;  //Modification

   Total : Integer;


begin

   Acc := thisisaccess'Access; //Modification
   Acc2 := Acc; //Modification
   Acc2.all; //Modification

       AnimalPKG.Animals(Total, 3,2,1); 
       Put(Total); 
       Acc.all; 
       passinfunction(Acc); 
       Put(B(3)); 
    end Main;

.all 构造是显式取消引用。编译器无法以其他方式判断 Paccess procedure 类型,您是指 指针 本身,还是 调用。请注意,在 Ada 中调用过程时不需要空括号。因此 P 被理解为指针本身,而 P.all 被理解为调用。