RValue DIP Draft.

Elronnd elronnd at elronnd.net
Tue Oct 19 03:53:45 UTC 2021


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).

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.)


More information about the Digitalmars-d mailing list