[fpc-devel] Move operator

Michael Van Canneyt michael at freepascal.org
Sun Jul 14 17:58:37 CEST 2019



On Sun, 14 Jul 2019, Ryan Joseph wrote:

>
>
>> On Jul 14, 2019, at 8:55 AM, Jonas Maebe <jonas at freepascal.org> wrote:
>> 
>> The question then still remains: why would a user want to call a copy
>> operator when the data is just moved from a temp to another place?
>> Having an explicit copy operator when there is no use case for it only
>> requires programmers to write extra code that can contain bugs.
>
> Your point is well taken but I really don’t have any better answer than it doesn’t feel balanced with the copy operator in that same level of control to the user. Using the management operators it feels like your opting into having the compiler tell you when it’s performing certain operations on the record so it feels wrong that the move operation is happening without telling you. Just my feelings though. :)
>
> Do you have another proposal then?  If there’s no move operator then
> there’s no way to signal that a move is going to override the usual copy
> operator call which happens every time.  I guess the only other viable
> option would be a modeswitch or some other compiler directive to toggle
> on/off.

You are assuming here that there is a problem. Has it occurred to you that
maybe there is no problem and that a solution is simply not needed?

Sounds to me like you're simply needlessly complicating simple things:
moving data from one location in memory to another.

Michael.


More information about the fpc-devel mailing list