Ada:编译指示列表
Ada: Pragma List
谁能告诉我 Pragma List 的作用(具体来说,什么是“编译列表”)?我不明白 LRM 的描述(2.8.25)
A pragma List takes one of the identifiers On or Off as the single argument. This pragma is allowed anywhere a pragma is allowed. It specifies that listing of the compilation is to be continued or suspended until a List pragma with the opposite argument is given within the same compilation. The pragma itself is always listed if the compiler is producing a listing.
您应该回想一下编译器在 1970 年代后期是如何工作和使用的。我很确定意思和它写的一样简单(用 "outputs" 代替 "is producing",以获得更现代的措辞)。
with Ada.Text_IO;
-- Now you see me.
pragma List (Off);
-- Now you do not.
private with Some_Secret_Package;
pragma List (On);
package Hello_World is
...
编译器可以输出,即“列出”其输入,以及它将生成的任何消息,例如错误消息。当您想要在上下文中清楚、详细地了解消息的内容时,这很有用。 IDE 通常会将 link 消息发送给代码,但即使在今天,考虑到 对计算历史的提示,列表也可以逐字指出。使用 pragma List
,程序员可以排除不需要列出的内容(如果他或她知道的话)。或者,出于保密原因,排除不应列出的内容。
先是列表,再是原程序正文,pragma List
:
Compiling: /some/path/some_proc.adb
Source file time stamp: 2017-01-30 08:30:40
Compiled at: 2017-01-30 09:30:42
1. procedure Some_Proc is
2. procedure Inner;
3. -- Does this and that...
4.
5. pragma List (Off);
10. pragma List (On);
11.
12. begin
13. Inner (42);
|
>>> too many arguments in call to "Inner"
14. end Some_Proc;
14 lines: 1 error
gprbuild: *** compilation phase failed
(如果你的编译器是GNAT,在开关中指定-gnatl
,用于列表和编译:)
procedure Some_Proc is
procedure Inner;
-- Does this and that...
pragma List (Off);
procedure Inner is
begin
null;
end Inner;
pragma List (On);
begin
Inner (42);
end Some_Proc;
谁能告诉我 Pragma List 的作用(具体来说,什么是“编译列表”)?我不明白 LRM 的描述(2.8.25)
A pragma List takes one of the identifiers On or Off as the single argument. This pragma is allowed anywhere a pragma is allowed. It specifies that listing of the compilation is to be continued or suspended until a List pragma with the opposite argument is given within the same compilation. The pragma itself is always listed if the compiler is producing a listing.
您应该回想一下编译器在 1970 年代后期是如何工作和使用的。我很确定意思和它写的一样简单(用 "outputs" 代替 "is producing",以获得更现代的措辞)。
with Ada.Text_IO;
-- Now you see me.
pragma List (Off);
-- Now you do not.
private with Some_Secret_Package;
pragma List (On);
package Hello_World is
...
编译器可以输出,即“列出”其输入,以及它将生成的任何消息,例如错误消息。当您想要在上下文中清楚、详细地了解消息的内容时,这很有用。 IDE 通常会将 link 消息发送给代码,但即使在今天,考虑到 pragma List
,程序员可以排除不需要列出的内容(如果他或她知道的话)。或者,出于保密原因,排除不应列出的内容。
先是列表,再是原程序正文,pragma List
:
Compiling: /some/path/some_proc.adb
Source file time stamp: 2017-01-30 08:30:40
Compiled at: 2017-01-30 09:30:42
1. procedure Some_Proc is
2. procedure Inner;
3. -- Does this and that...
4.
5. pragma List (Off);
10. pragma List (On);
11.
12. begin
13. Inner (42);
|
>>> too many arguments in call to "Inner"
14. end Some_Proc;
14 lines: 1 error
gprbuild: *** compilation phase failed
(如果你的编译器是GNAT,在开关中指定-gnatl
,用于列表和编译:)
procedure Some_Proc is
procedure Inner;
-- Does this and that...
pragma List (Off);
procedure Inner is
begin
null;
end Inner;
pragma List (On);
begin
Inner (42);
end Some_Proc;