[fpc-pascal] Managed record questions

Ryan Joseph ryan at thealchemistguild.com
Fri Mar 9 09:12:23 CET 2018



> On Mar 9, 2018, at 1:53 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> They are broken, deprecated and essentially dead in Delphi, but in FPC we've always cared for them as well.
> Overloads and generics are already supported and support for helpers could be easily added. Only major feature missing compared to classes is the support for extensive RTTI. 

Out of curiosity I did some quick tests and learned a few things:

1) Interfaces don’t work as far as I can tell (too bad)
2) The constructor/destructor situation is pretty messy (deref using ^ could be omitted like classes probably) but that’s how they were in the past.
3) I suppose it never existed but “override” missing is pretty strange. Historical I guess.
4) Move() on an object copies memory like a record (as a record does, so this is good). Does that mean they laid out in memory just like records?

So why do we have advanced records then if objects do more than records? The overhead of a virtual method table? Records have a better/cleaner syntax for operator overloads than even classes but what else?

Unlike C++ the object’s destructor was not called when it went out of scope but if it did that they would be an interesting replacement for classes in some cases. The compiler knows how to cleanup stack variables but does it call any virtual method on objects in this situation?

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list