[fpc-devel] weak referencing (was Suggestion:.....)

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Sep 25 18:11:37 CEST 2014

On 22/09/14 19:21, Sven Barth wrote:
> Am 22.09.2014 17:11 schrieb "Jonas Maebe" <jonas.maebe at elis.ugent.be
> <mailto:jonas.maebe at elis.ugent.be>>:
>> On 22 Sep 2014, at 16:44, Peter Popov wrote:
>>> TRefObject = referenced class(TWhateverBase)
>>> end;
>> I would strongly recommend against that. Referenced and unreferenced
>> objects are completely different beasts with different behaviours. If
>> you allow that, you get all kinds of problems down the line. E.g. you
>> either have to forbid assigning a TRefObject to a TWhateverBase (which
>> runs counter to a very basic OOP principle), or allow it and then have
>> the programmer deal with the resulting reference counting mess-ups.
> As written in my RFC I would go the "allow it" route and provide
> mechanisms to manually access the reference count from a non-reference
> counted variable (thus being implemented in TObject). Optionally one
> could add a warning that is off by default that one could use for such
> cases. This approach is necessary, because we'd otherwise need to
> introduce overloads for e.g. RTTI functionality in TypInfo or to
> introduce some compiler magic for them (I don't like either of these two
> possibilities).

You can do it in the same way as we handle ansistrings with different
codepages in the RTL (with a procedure modifier). I really think they
should be completely incompatible entities that have nothing to do with
each other whatsoever at the language level, since they have to be
handled completely differently by the compiler. Just like Objective-C,
C++ classes and TP-style objects.


More information about the fpc-devel mailing list