On Thu, Apr 25, 2024 at 11:18 AM Sven Barth via fpc-devel <fpc-devel@lists.freepascal.org> wrote:
> 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). OK, that makes sense. > 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 > https://wiki.freepascal.org/management_operators So, I would have to declare something like this? class operator TArr.Copy(constref aSrc: TArr; var aDst: TArr); begin aDst.A := Copy(aSrc.A); end; And then in my example: R1.A := [1,2,3]; R2 := R1; --> R2.A will be (1,2,3), and changing that will not affect R1.A anymore Sounds like a nice feature to have (in 3.4). I'll write some tests to get familiar with this and if I don't forget I'll write a simple example in the wiki (there's a ToDo for that currently). -- Bart _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel