[fpc-devel] Modernising Pascal

peter green plugwash at bircd.org
Wed Feb 23 00:57:36 CET 2005

> 1. Memory management. Delphi is quite incosistent here by allowing
> component classes to be auto managed (via their owner) whilst
> non-component class have to be manually managed. The best solution I can
> think for this is to reference count non-component classes. This should
> be safe for TObjects but obviously not for Tcomponent descendants (cf
> circular reference problem) so a protected variable could be added to
> TObject to specify whether to ref count it or not (with TComponent
> turning it off). This will improve legibility of code too as there will
> no longer be a need for having loads of try..finally statements to free
> stuff. Backwards compatibility should not be affected so if you call a
> free method it will free it whatever its ref count.
there would be quite some performance penalty to this. Refcounting is
actually quite expensive especially because of the way it adds loads of
extra try-finally blocks to the asm.

furthermore how do you propose to do such a thing while maintaining the
capability to typecast safely back and forward between object types and
integer types which so much code relys on.

More information about the fpc-devel mailing list