如何重命名受保护对象条目
How to rename protected object entry
我想重命名 Synchronized_Queue_Interface Enqueue 条目,但不知道如何正确执行。
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.Enqueue
与 Boolean_Queues.Queue.Enqueue
)。 -- 解决这个问题的最好方法是明确:
procedure Do_it( Item : Boolean )
renames Boolean_Queues.Queue(Queue).Enqueue;
您可能应该提交错误报告,当然要求更好的错误消息。
我想重命名 Synchronized_Queue_Interface Enqueue 条目,但不知道如何正确执行。
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.Enqueue
与 Boolean_Queues.Queue.Enqueue
)。 -- 解决这个问题的最好方法是明确:
procedure Do_it( Item : Boolean )
renames Boolean_Queues.Queue(Queue).Enqueue;
您可能应该提交错误报告,当然要求更好的错误消息。