[fpc-pascal] Object questions

Ryan Joseph ryan at thealchemistguild.com
Tue Dec 4 03:36:14 CET 2018


Some questions about old-style objects.

1) How can you check if self is assigned? self refers to the struct itself but if the object was allocated on the stack then how do we know self is a pointer or not?

procedure TMyObject.Free;
begin
  if self <> nil then
    dispose(self,Destroy);
end;

2) Is there any TObject support in objects? I know there is a VMT table for objects but I’m not sure if it’s structure is public in the RTL. 

class function TMyObject.ClassName:string;
begin
  result := PVmt(self)^.vClassName^;
end;

3) why are operator overloads not supported in objects? Is there a technical reason for that?

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list