RValue DIP Draft.
Tejas
notrealemail at gmail.com
Tue Oct 19 06:05:25 UTC 2021
On Tuesday, 19 October 2021 at 03:53:45 UTC, Elronnd wrote:
> I support this DIP. However:
>
>> For objects larger than 1-2 registers in size, passing by
>> pointer may be more efficent than passing by value
>
> I don't buy this
>
> Really, there are two issues being brought up:
>
> 1. Copying large objects is slow
>
> 2. Copy constructors may be slow
>
> 1 is exclusively an ABI issue, and should be solved at the ABI
> level (cf
> https://elronnd.net/writ/boring/2021-05-07_abi-wrong.html).
>
Even `preview=in` subscribes to this philosophy and implements
the same semantics, so idk if anyone will ever implement changes
at ABI level.
> Regarding 2, consider that this DIP applies to rvalues. That
> is, it applies to expressions like:
>
> some_func(SomeStructWithAnExpensiveCopy())
>
> The proper fix for this is to turn the last use of a struct
> into a move instead of a copy. (I believe there was a DIP
> proposing this.)
It was DIP 1040 that was introducing move constructors,
moveAssign (and possiby rvalue references), but it's currently
not being worked on :(
More information about the Digitalmars-d
mailing list