DIP 1014

Shachar Shemesh shachar at weka.io
Thu Oct 4 08:32:44 UTC 2018


On 04/10/18 11:16, Paolo Invernizzi wrote:
> While I want to thank you both, about the quality of this thread, what 
> kind of "consequences that go beyond what I think you understand" are 
> you thinking of? Can you give an example?

Assuming I understand Stanislav's proposal correctly (an assumption I'm 
reluctant to make, hence my request for something more formal), it boils 
down to two points:

* move the data as part of the call hook rather than before
* Use a different name and signature on the hook function

The first one we can argue for or against. My original proposal was 
phrased the way it was precisely because that's the way copying works in 
D (copy first, patch the data later). About a week after I submitted it, 
Andrei came forward with requesting to move to copy constructors.

The second, to me, is a non-starter. The only way you'd get a function 
who's signature is:
void someName(Type rhs);

But which actually maintains rhs's address from before the call is if 
the compiler treats "someName" as a special case, and emits code which 
would normally be emitted for the function:

void someName(ref Type rhs);

That's why it was important for me to clear up whether there is *ever* a 
case in the current language where that happens (answer: only by 
accident, which is the same as saying "no").

So to get that to work, you'd need to insert a special case into the ABI 
of the language: if the function's name is someName, treat it differently.

At this point, you might as well call a spade a spade, and just give the 
function that signature explicitly. s/someName/opPostMove/, and you get 
DIP 1014 (as far as point #2 is concerned).

Shachar


More information about the Digitalmars-d mailing list