Link to Lazarus forum thread with reference counting discussion: http://forum.lazarus.freepascal.org/index.php/topic,22231.0.html
My opinion: yes, this feature should be implemented.
And yes it should be optional (either additional root object or local compiler switch), so that existing code could remain unmodified.
20.09.2014, 19:00, "Hans-Peter Diettrich" <drdiettri...@aol.com>:
Sven Barth schrieb:On 20.09.2014 12:36, Hans-Peter Diettrich wrote:[...]AFAIK some Delphi XE made TObject itself managed, by reference counting.It's basically easy, yes, but then one has to deal with code like this:
It would be easy to introduce the same feature in FPC, so that no
special base class would be required. Like with extended RTTI a decision
should be made, whether managed objects should be enabled or disabled by
default. Afterwards automatic management can be turned on or off for
every single class or object individually.Which could lead to some unintended side effects if "o" is passed toI already mentioned that destructors still are required, but will have
some other code which keeps the instance around and ".Free" merely
decreases the reference count. Of course that would have been a memory
leak before and now it's not, but nevertheless it changes behavior.
an different purpose and usage than before. This would discourage
continued use of Destroy(), BeforeDestruction() etc., which should at
least be renamed to prevent unconverted legacy code from compiling. This
change already will break compatibilitiy, so that consequently all
libraries (in detail when dealing with lists containing objects) have to
be updated. I was aware of such consequences, but I'm no more sure of
the consequences of my idea of simply turning refcounting on or off for
specific objects or classes.
The mere implementation of refcounting for TObject is easy, but the
consequences are hell :-(
DoDi
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel