<p>Am 21.07.2017 23:36 schrieb "Ryan Joseph" <<a href="mailto:ryan@thealchemistguild.com">ryan@thealchemistguild.com</a>>:<br>
><br>
> Thanks Sven, that’s one way around it.<br>
><br>
> So is it by design that records don’t have inheritance or is this planned?</p>
<p>Yes, that's by design and there are no plans to change this.</p>
<p>> and is it also by design that classes don’t allow operator overloads inside them? That seems like an omission since the way they’re implemented in records is much nicer imo.</p>
<p>There are two points you need to be aware of to understand why thinks are the way they are:<br>
First of global operator overloads were the first that were implemented in FPC. Then Delphi came along and added record operator overloads, because they needed them for generics. FPC followed, cause the global overloads are useless in that case.<br>
Secondly even for global operator overloads classes are not really that suitable, cause in complex expressions (let's say "a * (b + c)") you'll have the generation of temporary variables (in the example the result of "b + c"), but the compiler can't know whether it's really a temporary value that it can free after the whole expression is handled or whether merely the instance that had been passed in (let's say "b") had been modified and passed as a result. Thus operator overloads for classes can easily lead to memory leaks or other hard to debug problems. Yes, that's already possible with global operators as well, but with operators that are part of the class that would be much more inviting.</p>
<p>Regards,<br>
Sven</p>