Have anybody considered dedicating a specific operator for pass-by-move semantics in assignments and argument passing?
For instance,
y = x;
z = f(y);
copies x
and y
whereas
y = <<x;
z = f(<<y);
moves x
and y
.
Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 19, 2022 Operator for pass by move | ||||
---|---|---|---|---|
| ||||
Have anybody considered dedicating a specific operator for pass-by-move semantics in assignments and argument passing? For instance,
copies
moves |
December 19, 2022 Re: Operator for pass by move | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 19 December 2022 at 11:12:54 UTC, Per Nordlöw wrote: >Have anybody considered dedicating a specific operator for pass-by-move semantics in assignments and argument passing? Is |
December 21, 2022 Re: Operator for pass by move | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Monday, 19 December 2022 at 17:43:12 UTC, Paul Backus wrote: >On Monday, 19 December 2022 at 11:12:54 UTC, Per Nordlöw wrote: >Have anybody considered dedicating a specific operator for pass-by-move semantics in assignments and argument passing? Is There is no reason for either. The compiler should definitively be able to move things when appropriate (if they are not reused after) and this is allowed by the current spec. |
December 21, 2022 Re: Operator for pass by move | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 12/21/22 17:50, deadalnix wrote:
> On Monday, 19 December 2022 at 17:43:12 UTC, Paul Backus wrote:
>> On Monday, 19 December 2022 at 11:12:54 UTC, Per Nordlöw wrote:
>>> Have anybody considered dedicating a specific operator for pass-by-move semantics in assignments and argument passing?
>>
>> Is `core.lifetime.move` not good enough?
>
> There is no reason for either.
>
> The compiler should definitively be able to move things when appropriate (if they are not reused after) and this is allowed by the current spec.
The reason is that you may want to be explicit about your moves and have the type checker complain if it's actually used again. (This is also why core.lifetime.move is not great.)
|