[fpc-devel] Suggestion: reference counted objects

Boian Mitov mitov at mitov.com
Tue Sep 23 02:11:05 CEST 2014

Because TObject always has virtual table as example, and you can't use 
anything inherited from it to map into communication header.
Structures on another hand by default start from empty hierarchy, and do not 
have Virtual Table pointer so I can create a structure and send it to a 
socket for transmission or map an received array into structure for easy 
Unfortunately headers tend to have hierarchies ;-) , shich makes it a bit 
challenging to map them into Delphi records, or use the same function to 
process inherited record as example ;-) .
I know there are some not that pretty works around this, but that is what 
they are - ugly, and sometime dangerous(ahem... unsafe casting) work 

With best regards,
Boian Mitov

Mitov Software
-----Original Message----- 
From: Hans-Peter Diettrich
Sent: Monday, September 22, 2014 4:58 PM
To: FPC developers' list
Subject: Re: [fpc-devel] Suggestion: reference counted objects

Boian Mitov schrieb:
> In general, records and classes are inherently the same thing (and in C++ 
> are indeed practically interchangeable).

This model might have been the reason for introducing Object at all, for
compatibility with CBuilder.

> The only real difference in Delphi/FPC is that records are instantiated in 
> the stack, the objects in the heap,

Like records, Objects can reside in either the stack, heap or even
static memory.

> and the artificial restriction on record inheritance.

Why inherit when you can't override virtual methods? I convert my
Records into Objects, when I want to extend an record.


fpc-devel maillist  -  fpc-devel at lists.freepascal.org

More information about the fpc-devel mailing list