Sign in Join

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

Mailing lists / fpc-pascal / 2017-01

destructor

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Mattias Gaertner

Hi,

fpc allows to declare a method with the destructor keyword, that is not a real destructor, because it does not free the memory. For what is this feature good for?
For example:

Type
  TClassA = class
  public
    destructor Foo;
  end;
destructor TClassA.Foo;
begin
end;
var
  o: TClass;
begin
  o:=TClass.Create;
  o.Foo; // does not call FreeInstance
  o.Destroy; // does call FreeInstance
end.

Mattias

Maciej Izak
to Mattias Gaertner

2017-01-24 12:48 GMT+01:00 Mattias Gaertner :

fpc allows to declare a method with the destructor keyword, that is not a real destructor, because it does not free the memory. For what is this feature good for?

with trunk works as expected (Foo does call FreeInstance).

Best regards, Maciej Izak
Mattias Gaertner
to Maciej Izak
Show quoted text 8 lines
2017-01-24 12:48 GMT+01:00 Mattias Gaertner : > fpc allows to declare a method with the destructor keyword, that is > not a real destructor, because it does not free the memory. For what is > this feature good for? > with trunk works as expected (Foo does call FreeInstance).

True.
Sorry, I mixed two destructors. Now I understand the Note: Class should have one destructor only.

Mattias