Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 如何使类完成即使对于空参数列表也包含括号?_Delphi_Ide_Class Completion - Fatal编程技术网

Delphi 如何使类完成即使对于空参数列表也包含括号?

Delphi 如何使类完成即使对于空参数列表也包含括号?,delphi,ide,class-completion,Delphi,Ide,Class Completion,在Visual Studio工作了几年后,我又回到了Delphi 2010。我想让IDE以不同的方式运行: 我希望IDE的自动完成在我声明函数/过程时尊重括号。示例:如果我声明过程x();我希望自动完成来创建过程myobj.x()和NOT程序myobject.x就是这样。是的,这并不重要,但我很迂腐。有什么想法吗?好吧,没办法 对象Pascal在没有参数(正如Ken所说)的情况下不需要括号,所以它是无害的 注:在VS语言中(特别是在VB.NET中),即使是非参数化例程也需要括号,这是最烦人和刺激

在Visual Studio工作了几年后,我又回到了Delphi 2010。我想让IDE以不同的方式运行:


我希望IDE的自动完成在我声明函数/过程时尊重括号。示例:如果我声明过程x();我希望自动完成来创建过程myobj.x()和NOT程序myobject.x就是这样。是的,这并不重要,但我很迂腐。有什么想法吗?

好吧,没办法

对象Pascal在没有参数(正如Ken所说)的情况下不需要括号,所以它是无害的


注:在VS语言中(特别是在VB.NET中),即使是非参数化例程也需要括号,这是最烦人和刺激的事情之一。当然,只是我

Delphi在没有参数时不需要括号;我怀疑这是可能的

在接口或实现中,它应该无关紧要,因为它是一个方法声明这一事实是显而易见的

function TMyClass.IsDefaultPropValue: Boolean;
我可以看出,在调用该方法的实际代码中,它会起到什么作用,您可能希望澄清它不是一个变量,如

// Unit MyClass
type
  TMyClass=class(TSomething)
  public
    function IsDefaultPropValue: Boolean;
  end;

// In a far distant block  of code in another unit that uses the above unit, using the
// nasty "with" (not you, of course - one of your coworkers):
with MyClassInstance do
begin
  // More lines of code. FirstPass is a local boolean variable.
  if FirstPass then
  begin
    if IsDefaultPropValue then
    begin
      // More lines of code
    end
    else
    begin
      // Alternate branch of code 
    end;
  end
  else
  begin
    if IsDefaultPropValue then
    //.....
  end;
end;
在本例中,不清楚
IsDefaultPropValue
是否是一个函数而不是布尔变量,我会将其用作

if IsDefaultPropertyValue() then ... 

// or better yet: 
if MyClassInstance.IsDefaultPropValue() then ...

要说清楚。

事实上,标准Pascal禁止使用这种“装饰性”括号。不仅是VS,它在大多数流行语言中都很常见。但至少比VB在将函数作为过程调用时(不存储结果)禁止使用括号的习惯要好。您只需列出不带括号的参数,而在常规函数调用中,这些参数是必需的:D@GolezTrol:我想这让人想起了古老的
调用
指令(顺便说一句,它仍然存在于Visual Basic.Net中)。