[fpc-devel] Suggestion: reference counted objects
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Mon Sep 22 11:04:35 CEST 2014
Sven Barth schrieb:
> On 21.09.2014 21:09, Hans-Peter Diettrich wrote:
>> Sven Barth schrieb:
[...]
>> I'd add a _RefCount field to TObject, regardless of whether it's really
>> used later; this will fix the field offset - just like the VMT reference
>> is fixed in TObject, but not in Object types. This will eliminate
>> problems with class helpers.
>
> I've especially written that it's not part of *every* objects, because
> people complained about the size increase for all instances.
That's why I also suggested an compiler option, useful for all people
which care about program size or ARC at all.
In general I agree with your thoughts, I only wanted to add a few remarks.
[...]
>> Here the compiler would always insert _AddRef, just like with
>> interfaces, eventually optimized (inlined?) like:
>> if Result._RefCounter <> -1 then
>> Result._AddRef; //or InterlockedIncrement(Result._RefCounter);
>
> And that's another thing: people complained about having that reference
> count overhead for *all* assignments.
See above :-)
[...]
> It. Was. Just. An. Example. To. Illustrate. The. Problem!
> I would implement that differently as well, but there's *no* point to do
> that inside an example that's supposed to be as simple as possible!
Is it me, or what else makes you so angry today?
Sorry for that :-(
Regards
DoDi
More information about the fpc-devel
mailing list