[fpc-devel] Pointer cache for fast class/pointer access.

Skybuck Flying skybuck2000 at hotmail.com
Mon Jan 2 12:22:03 CET 2012


Something like this ;):

type
TDepth3 = class
public
  mValue : integer;

  constructor Create;
  destructor Destroy; override;
end;

constructor TDepth3.Create;
begin
mValue := 666;
end;

destructor TDepth3.Destroy;
begin

end;

type
TDepth2 = class
public
  mDepth3 : TDepth3;

  constructor Create;
  destructor Destroy; override;
end;

constructor TDepth2.Create;
begin
mDepth3 := TDepth3.Create;
end;

destructor TDepth2.Destroy;
begin
mDepth3.Free;
end;

type
TDepth1 = class
public
  mDepth2 : TDepth2;

  constructor Create;
  destructor Destroy; override;
end;

constructor TDepth1.Create;
begin
mDepth2 := TDepth2.Create;
end;

destructor TDepth1.Destroy;
begin
mDepth2.Free;
end;


procedure Demo1;
var
mDepth1 : TDepth1;
vValue : integer;
begin
mDepth1 := TDepth1.Create;
vValue := mDepth1.mDepth2.mDepth3.mValue;
writeln( 'vValue: ', vValue );
mDepth1.Free;
end;

I consider .mDepth2.mDepth3 nested classes ;)

Bye,
  Skybuck.



More information about the fpc-devel mailing list