[fpc-devel] Proof of Concept ARC implementation
Michael Van Canneyt
michael at freepascal.org
Mon Oct 27 19:24:51 CET 2014
On Mon, 27 Oct 2014, Sven Barth wrote:
>
> 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.
There *will* be a performance impact, and there *are* circular references.
You cannot simply minimize either of these facts away:
Reference counting of all objects is not some nice-to-have "feature".
It is a complete shift in paradigm at the very root of the language.
You would need to write a different RTL entirely which is aware of this paradigm.
If you have reference counted objects, you can make strings into real objects etc.
No problem with all that, interesting ideas even, but not with the current codebase and RTL.
Michael.
More information about the fpc-devel
mailing list