[fpc-pascal] sqldb create/free lifetime of object
Michael Van Canneyt
michael at freepascal.org
Wed Apr 12 15:05:38 CEST 2017
On Wed, 12 Apr 2017, noreply at z505.com wrote:
> On 2017-04-12 05:03, LacaK wrote:
>> Yes, example should be adjusted. Please report bug to not forget.
> It is not a bug, I just wanted to clarify the magic going on behind the
> scenes - which, is "ownership".
> That's all I needed to know.
> The key to seeing this trick/magic is in the Create function where you
> pass in the C (connection) as the owner.
> But on my cell phone I didn't really see this, and, it's not always
> obvious.. hence my gripe.
> In a way, this is a form of garbage collection or RAII sort of. And
> reduces the obnoxious free's required in non garbage collected
> programming languages... So it's a nice feature/trick to have ownership.
It's one of the reasons I descend most of my classes from TComponent;
the cleanup is then automatic...
More information about the fpc-pascal