[fpc-devel] Modernising Pascal

Jamie McCracken jamie-junk at blueyonder.co.uk
Wed Feb 23 01:26:11 CET 2005


peter green wrote:
>>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.

not much more cause you would still need try finally blocks in most 
cases for robust code. In other cases you can use a pointer to avoid 
overhead (IE in cases where you are not actually creating instances).

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

not sure I understand the problem here.  Can you give an example?

jamie.


> 
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
> 
> 





More information about the fpc-devel mailing list