什么可以让一个简单的 ada 程序的输出在没有被告知时缩进?

What can make the output of a simple ada program indent, when not told to?

我目前正在学习 learn.adacore.com 的 Ada 教程,我现在正在学习第二个示例:读取和输出整数。由于复制粘贴适合不想学习语法的人,所以我手动输入了大部分代码(其中一些是gnat-gps生成的,但我现在使用vim)。

我编译并 运行 程序,令人惊讶的是,第二行输出大约缩进了一个制表符。为什么?

代码如下:

With Ada.Text_IO;
Use Ada.Text_IO;
With Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;

procedure Main is
    N : Integer;
begin
   --  Insert code here.
    Put("Enter an integer value: ");
    Get(N);
    if N>0 then
        Put (N);
        Put_Line(" is a positive number");
    end if;
end Main;

(如何获得语法高亮?)

这是输出示例(输入第一个 1):

Enter an integer value: 1
          1 is a positive number

Ada.Integer_Text_IO 中的 Put 过程使用用空格填充的默认字段宽度。 该过程的规范在 Ada Language Reference Manual 中定义为:

procedure Put(Item  : in Num;
              Width : in Field := Default_Width;
              Base  : in Number_Base := Default_Base);

Width 和 Base 参数具有默认值。您对 Put 的调用只为形式参数 Item 提供了一个值。要消除左填充,只需指定所需的宽度即可。我建议您使用 Ada 命名符号进行调用,如

Put(Item => N, Width => 1);