-gnatyo 实际执行什么样式检查?
What style checking does -gnatyo actually perform?
manual 内容为:
Check order of subprogram bodies. If the letter o appears in the string after -gnaty then all subprogram bodies in a given scope (e.g. a package body) must be in alphabetical order. The ordering rule uses normal Ada rules for comparing strings, ignoring casing of letters, except that if there is a trailing numeric suffix, then the value of this suffix is used in the ordering (e.g. Junk2 comes before Junk10).
我认为 Junk2
取代 Junk10
是对其他奇怪风格执法的真正灵感。但是实际触发它的某些代码的示例是什么?我无法得到这个选项来抱怨无序的函数定义或任务体。例如,在使用 gnat make -gnatyo
:
编译以下内容时,我没有收到任何投诉
procedure Disordered is
function Test return Natural;
function Zest return Natural;
-- disordered function bodies
function Zest return Natural is (1);
function Test return Natural is (2);
begin
null;
end Disordered;
你有:
-- disordered function bodies
function Zest return Natural is (1);
function Test return Natural is (2);
但从技术上讲,这些不是子程序主体。它们被称为表达式函数。这种明确区分的原因是包规范中不允许使用子程序主体,而表达式函数则可以。
在您的示例中使用实际的子程序主体将给出预期的样式警告:
function Zest return Natural is
begin
return 1;
end Zest;
function Test return Natural is
begin
return 2;
end Test;
(因为你提到了任务体;那些也不是子程序体)
manual 内容为:
Check order of subprogram bodies. If the letter o appears in the string after -gnaty then all subprogram bodies in a given scope (e.g. a package body) must be in alphabetical order. The ordering rule uses normal Ada rules for comparing strings, ignoring casing of letters, except that if there is a trailing numeric suffix, then the value of this suffix is used in the ordering (e.g. Junk2 comes before Junk10).
我认为 Junk2
取代 Junk10
是对其他奇怪风格执法的真正灵感。但是实际触发它的某些代码的示例是什么?我无法得到这个选项来抱怨无序的函数定义或任务体。例如,在使用 gnat make -gnatyo
:
procedure Disordered is
function Test return Natural;
function Zest return Natural;
-- disordered function bodies
function Zest return Natural is (1);
function Test return Natural is (2);
begin
null;
end Disordered;
你有:
-- disordered function bodies
function Zest return Natural is (1);
function Test return Natural is (2);
但从技术上讲,这些不是子程序主体。它们被称为表达式函数。这种明确区分的原因是包规范中不允许使用子程序主体,而表达式函数则可以。 在您的示例中使用实际的子程序主体将给出预期的样式警告:
function Zest return Natural is
begin
return 1;
end Zest;
function Test return Natural is
begin
return 2;
end Test;
(因为你提到了任务体;那些也不是子程序体)