[fpc-pascal] Out of scope method?

Ryan Joseph ryan at thealchemistguild.com
Thu Apr 6 11:32:48 CEST 2017


> On Apr 6, 2017, at 4:26 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> It's a difficult topic, cause in Object Pascal class instances are always on the heap while in C++ they might be on the stack as well. Thus a C++ compiler will insert calls to the destructor of such an object if it goes out of scope.
> 
> In Object Pascal currently only reference counted interfaces and (new in trunk) records with management operators provide this feature.

I see, but since there is a reference to an instance on the stack wouldn’t it be trivial for the compiler to invoke a method on TObject descendants when they go out of scope? If it does it for compiler types like dynamic arrays I imagine it could do the same for classes.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list