How can I make Class Completion include parentheses even for empty parameter lists?

381 views Asked by At

I'm back in Delphi 2010 again after having worked several years in Visual Studio. I would like to make the IDE behave in a differnet way:

I'd like the IDE's auto-completion to respect the parenthesis when I declare a function/procedure. Example: if I declare procedure x(); Id like the auto-completion to create procedure myobj.x(); and NOT procedure myobject.x; as it does. Yes, it doesn't really matter but I'm pedantic. Any ideas?

2

There are 2 answers

3
Fabricio Araujo On

AFAIK, there's no way.

Object Pascal doesn't require parenthesis when you have (as Ken said) no parameters - so it's harmless.

PS.: The need for parenthesis even for non-parameterized routines is one of the most pesky and irritant things in VS languages (particularly in VB.NET). Of course, it's just IMHO...

0
Ken White On

Delphi doesn't require the parentheses when there are no parameters; I doubt this is possible.

It shouldn't matter in the interface or implementation, where the fact that it's a method declaration is clear.

function TMyClass.IsDefaultPropValue: Boolean;

I can see where it would matter in actual code that calls the method, where you would want to clarify that it was not a variable, as in

// 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;

In this case, it's not clear that IsDefaultPropValue is a function and not a Boolean variable and I'd use it as

if IsDefaultPropertyValue() then ... 

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

to make it clear.