Destructors in records (BDS2006)

Giganews Newsgroups
Subject: Destructors in records (BDS2006)
Posted by:  Timokhov Dimitry (dtimokh…@vkkb.ru)
Date: Tue, 28 Mar 2006

Good day.

As I can see in manual destructors are not available in records.

How can I write method that will be automatically executed when record is
going out of scope?

For example.

type
  TMyRec = record
      procedure SomeMethod();
      procedure Destruction(); // analoque of destructor
  end;

procedure Test();
var
  R: TMyRec;
begin
  // SomeMethod allocates memory from heap.
  R.SomeMethod();
  // HERE I want to free memory allocated in SomeMethod by automatically
calling of TMyRec.Destruction
end;

Or I must explicitly call TMyRec.Destruction?

Replies