Am 09.03.2018 10:14 schrieb "Ryan Joseph" <r...@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.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to