rename - 如何重命名 protected 对象条目

标签 rename procedure ada protected

我想重命名 Synchronized_Queue_Interface 入队条目,但不知道如何正确操作。

with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Synchronized_Queues;

package Test is
   
   use Ada.Containers;
   
   package Boolean_Queue_Interfaces is new Synchronized_Queue_Interfaces
     (Element_Type => Boolean);
   
   package Boolean_Queues is new Unbounded_Synchronized_Queues
     (Queue_Interfaces => Boolean_Queue_Interfaces);
   
   Queue : Boolean_Queues.Queue;
   
   procedure Enqueue (New_Item : Boolean) renames Queue.Enqueue;  --  Illegal

end Test;

最佳答案

您需要使用的表格是这样的:

Protected Type Example is
    Entry Queue( Item : Integer );
Private
    Element : Integer := 0;
End Example;


Protected Body Example is
    Entry Queue( Item : Integer ) when true is
    Begin
        Element:= Item;
    End Queue;
End Example;    

V : example;

Procedure Q( X : Integer )
  renames V.Queue;

这就是您所拥有的,但是编译器似乎无法区分重载的形式(Boolean_Queue_Interfaces.Queue.EnqueueBoolean_Queues.Queue.Enqueue )。 -- 解决此问题的最佳方法是明确说明:

procedure Do_it( Item : Boolean )
  renames Boolean_Queues.Queue(Queue).Enqueue;

您可能应该提交一份错误报告,当然要求更好的错误消息传递。

关于rename - 如何重命名 protected 对象条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69145376/

相关文章:

bash - move 具有相同名称的多个文件并即时重命名它们

postgresql - 如何在选择查询 postgreSQL 中使用变量

在win32(xp、vista等)中将Lua绑定(bind)到Ada?

file - 无法在 Ada 95 中创建文件

generics - 有没有办法在 Ada(特别是 GNAT)中创建和重用方面集?

vb6 - 如何重命名 VB6 可执行文件?

python - 重命名 models.py 中的外键

android - 如何将文件重命名为 google drive rest api?改造2

mysql - 使用 MySQL 中的存储过程参数限制选定的行数

ssh - 如何在 TCL Expect 中的多个程序之间共享生成的 SSH 进程?