[fpc-devel] Copy/move operator
Ryan Joseph
genericptr at gmail.com
Tue Jun 18 00:01:44 CEST 2019
> On Jun 17, 2019, at 1:00 PM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>
> If we do this at all we should use a separate operator as those two are rather different operations and the compiler would already have figured out which of the two operations is needed and thus the code inside the operator doesn't need to do that anymore.
>
> That said this would require extending the RTL assignment helper.
>
> And the problems that Jonas mentioned are less problems inside the compiler, but problems inside the user code when they write their Move operator incorrectly. From great power comes great responsibility after all and I'm not sure whether we should provide the users with that much power.
I see. Looking at this on Sunday I see in assignment nodes fpc_copy_proc would need to be modified or a new fpc_move_proc introduced which (for now at least) would only affect records which had a move operator. In theory the concept could be extended to dynamic arrays and other reference counted types but that’s another story.
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list