[fpc-devel] Proof of Concept ARC implementation

Sven Barth pascaldragon at googlemail.com
Mon Oct 27 17:58:48 CET 2014


Am 27.10.2014 17:20 schrieb "Hans-Peter Diettrich" <DrDiettrich1 at aol.com>:
>
> Jonas Maebe schrieb:
>
>
>> Additionally, as mentioned before, I still believe it's a very bad idea
to be able to inherited from a regular class and turn it into a reference
counted class. Reference counted and non-reference-counted
>> classes are different language entities with different behaviour and
different code generation requirements, and hence should be completely
unrelated.
>
>
> Something like ShortString and AnsiString?

With the difference that Short- and AnsiString are assignable to eachother
while Jonas does not want that for reference counted and ordinary classes.

>> Even if you completely forbid typecasting a reference counted class into
a non-reference-counted parent class, simply calling an inherited method
from a non-reference-counted parent class can easily completely mess up the
reference counting (e.g. suppose that inherited method inserts "self" into
a linked list).
>
>
> ACK. The only way out; I can see; is adding the *possibility* of
refcounting to TObject, meaning Add/ReleaseRef methods and a RefCount
field. Then the compiler can safely generate refcounting code for *all*
objects and non-weak references, and the counting methods take care of
required operations. Delphi offers two means for specialized refcounting,
the virtual counting methods, and the (COM compatible?) refcount value of
-1 for unmanaged objects.

What do you mean with "virtual counting methods"?
The main reason I decided not to introduce reference counting for every
class was that some people feared the performance impact of the reference
counting. Though Florian said that it shouldn't be that bad on today's
CPUs...
That said: if someone wants to test it one could add "refcounted" to
TObject (my code should(!) handle that correctly) and see what happens...
(of course there will be problems with circular references then)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20141027/d37ebf85/attachment.html>


More information about the fpc-devel mailing list