[fpc-pascal] Managed record questions

Sven Barth pascaldragon at googlemail.com
Fri Mar 9 10:51:37 CET 2018

Am 09.03.2018 10:14 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:

>> 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?
> Yes, although I believe there is a hidden VMT field.

Not sure how they look in memory but that code works so I guess they’re
safe to use as records. I could be wrong though and cause nasty bugs using
them as pure data structors (like passing to C functions!)

The VMT field exists if there is at least one virtual method.

>> 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?
> Simple: Delphi compatibility.
> You can probably find some of my cries of despair on the mailing lists,
> lamenting the fact that they decided to invent something new when they had
> it all along since many decades :(

I wonder how much code is shared between objects and records in the
compiler. It’s really just a syntax difference if all they really wanted
was Delphi compatibility. It’s a real shame to because the time could have
been spent making objects more unified with classes.

Objects share roughly as much code with records as classes do as internally
classes and objects share most of their code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180309/540d694c/attachment.html>

More information about the fpc-pascal mailing list