4

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?

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Lobuno
  • 1,405
  • 1
  • 18
  • 28

2 Answers2

1

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.

Ken White
  • 123,280
  • 14
  • 225
  • 444
0

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...

Fabricio Araujo
  • 3,810
  • 3
  • 28
  • 43
  • In the fact standard Pascal prohibits such "decorative" parenthesis. – Premature Optimization Oct 26 '11 at 20:47
  • Not just VS, it is common in most popular languages. But at least it's better than VB's habit of prohibiting parentheses when calling functions as procedures (without storing the result). You just have to list the parameters without parentheses, while in a regular function call, they are mandatory. :D – GolezTrol Oct 26 '11 at 23:21
  • @GolezTrol: I imagine this is a reminiscent of the ancient `call` instruction (which, by the way, still exists in Visual Basic.Net). – Fabricio Araujo Oct 27 '11 at 17:22