[fpc-pascal] Object questions

Sven Barth pascaldragon at googlemail.com
Tue Dec 4 11:26:39 CET 2018

Am Di., 4. Dez. 2018, 08:00 hat Ryan Joseph <ryan at thealchemistguild.com>

> > On Dec 4, 2018, at 1:52 PM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > The type of "Self" inside a object is always the same no matter if it's
> allocated on the stack or the heap.
> Then there’s now way to do a free method like I showed?


> >
> > 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;
> >
> > 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.
> I got a crash on that code but maybe it’s because of “self” or is the VMT
> table for objects not “VMT” from the RTL?

The VMT for objects is currently only available locally inside the Objects
unit (search for TVMT there).
There is a bug report however to publish it... Though even then it is much
less powerful than a class - there's a reason Borland reinvented the wheel


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181204/30c67713/attachment.html>

More information about the fpc-pascal mailing list