<div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr">Ryan Joseph <<a href="mailto:ryan@thealchemistguild.com">ryan@thealchemistguild.com</a>> schrieb am Fr., 17. Aug. 2018, 18:22:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Aug 16, 2018, at 8:55 AM, Sven Barth via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> wrote:<br>
> <br>
> It shouldn't be hard. Feel free to provide a patch together with some tests and it will be taken under consideration.<br>
<br>
So the reason that objects/classes in FPC don’t have operators in the class (like advanced records) is for Delphi compatibility? That would be great if operators were unified across records/classes.<br></blockquote></div><div dir="auto"><br></div><div dir="auto">Not entirely. In Delphi objects are deprecated, so as long as old code keeps compiling and running we can mess with them. </div><div dir="auto"><br></div><div dir="auto">However for classes there is the problem of temporary variables. Take a := b + c + d. That is essentially compiled as t := b + c; a := t + d. The compiler does not know whether the operator creates an instance or not (yes, there are circumstances when it can know that, but for the general case it can't) and thus this would potentially lead to memory leaks. </div><div dir="auto"><br></div><div dir="auto">Thus automatic reference counting or garbage collection or something like that is required for this to work nicely. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div>