<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Bart via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Mi., 24. Apr. 2024, 11:59:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Overloading the := (assignment) operator for equal types is forbidden.<br>
Out of curiosity I would like to know why that is?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">If there exists a built-in operator then overloading that operator is forbidden to avoid confusion when what operator might be used (operators can after all be declared *anywhere* and thus they might sometimes be used and sometimes not depending on which unit is used). </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
When you have e.g. a record definition containing a dynamic array, not<br>
being able to overload the assignment operator is just a PITA.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Then declare a Copy management operator in the record. Unlike an assignment operator these *must* be part of the record, thus the same rules are applied for the same type everywhere unlike for operator overloads. See also <a href="https://wiki.freepascal.org/management_operators">https://wiki.freepascal.org/management_operators</a> </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div></div>