[fpc-devel] Proof of Concept ARC implementation

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Oct 27 17:17:17 CET 2014


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?

I agree that a *compiler-based* implementation, of a single TObject base 
class, would require two sets of libraries, starting with the RTL, else 
a mix of units with different object types cannot be avoided in an 
executable. And it would almost disallow to use DLLs, of a possibly 
different model.

> 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.

DoDi




More information about the fpc-devel mailing list