<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Am Di., 4. Dez. 2018, 04:06 hat Ryan Joseph <<a href="mailto:ryan@thealchemistguild.com">ryan@thealchemistguild.com</a>> geschrieben:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Some questions about old-style objects.<br>
<br>
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?<br>
<br>
procedure TMyObject.Free;<br>
begin<br>
  if self <> nil then<br>
    dispose(self,Destroy);<br>
end;<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The type of "Self" inside a object is always the same no matter if it's allocated on the stack or the heap. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
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. <br>
<br>
class function TMyObject.ClassName:string;<br>
begin<br>
  result := PVmt(self)^.vClassName^;<br>
end;<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Objects don't have TObject-like functionality. There is a VMT record, but that is only available if there is at least one virtual method. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
3) why are operator overloads not supported in objects? Is there a technical reason for that?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Operator overloads inside records were added much later than support for global operator overloads and because of Delphi compatibility. Thus there was simply no need to add support for them. </div><div dir="auto">In addition to that one would need to dereference object pointer variables to use the operators (though that one is true for records as well). </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div>