Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-06

Codetools and virtual abstract methods (just nitpicking)

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Consider this code:

program test;
{$mode objfpc}{$H+}
{$R+}
uses sysutils, classes;
type
  { TCutomX }
  TCustomX = class (TStrings)
  protected
    procedure SomeProc; virtual; abstract;
  end;
  { TX }
  TX = class(TCustomX)
  protected
    procedure SomeProc; override; // Place cursor here
  end;
begin
end.

Now press Shift+Ctrl+C and voila codetools insert this code:

procedure TX.SomeProc;
begin
  inherited SomeProc;
end;
Which will (of course) not compile:
"test.lpr(32,21) Error: Abstract methods can't be called directly"

My fault, or a minor minor minor annoyance?

Bart

Reply by email

Mattias Gaertner
to Bart
Show quoted text 39 lines
Consider this code: program test; {$mode objfpc}{$H+} {$R+} uses sysutils, classes; type { TCutomX } TCustomX = class (TStrings) protected procedure SomeProc; virtual; abstract; end; { TX } TX = class(TCustomX) protected procedure SomeProc; override; // Place cursor here end; begin end. Now press Shift+Ctrl+C and voila codetools insert this code: procedure TX.SomeProc; begin inherited SomeProc; end; Which will (of course) not compile: "test.lpr(32,21) Error: Abstract methods can't be called directly" My fault, or a minor minor minor annoyance?

A minor.
There is already a mantis item for this.

Mattias

Reply by email

Hans-Peter Diettrich
to Bart: Consider this code: program test; {$mode objfpc}{$H+} {$R+} uses sysutils, classes; type…
Show quoted text 11 lines
Now press Shift+Ctrl+C and voila codetools insert this code: procedure TX.SomeProc; begin inherited SomeProc; end; Which will (of course) not compile: "test.lpr(32,21) Error: Abstract methods can't be called directly" My fault, or a minor minor minor annoyance?

It's liveable, I'd say. At least the compiler warns you, when you really forget to add meaningful code.

It's still better than other codetools behaviour, which don't recognize methods or fields in grandparents.

DoDi

Reply by email

Bart
to Mattias Gaertner: On Sun, 12 Jun 2011 12:25:58 +0200 A minor. There is already a mantis item for this.…
Mattias Gaertner wrote
A minor. There is already a mantis item for this.

Glad I didn't post it in Mantis then.
It's something I can live with.

This was my first time ever I wrote a component with an abstract method (not the example above, but a "real-life" one). Never really saw what it was good for, but suddenly it just seemed the right solution ;-)

Just keep on learning.

Bart

Reply by email