DIP 1014
Shachar Shemesh
shachar at weka.io
Wed Oct 3 15:33:00 UTC 2018
On 03/10/18 17:29, Stanislav Blinov wrote:
>> OMG, that's so simple!!! Why didn't I think of it?
>>
>> Oh wait, I did.
>
> Now I see why sometimes your posts are greeted with hostility.
Yes. I am actually sorry about that. I was responding to your assumption
that I'm wrong. Had your post been phrased as "why didn't you", instead
of "you're wrong wrong wrong" I wouldn't have responded that way.
Like I said, I am sorry.
> Allow me to further illustrate with something that can be written in
D > today:
I am not sure what you were trying to demonstrate, so instead I wanted
to see if you succeeded. I added the following to your Tracker struct:
~this() {
writefln("%s destructed", &this);
assert(counter is null || counter is &localCounter);
}
I.e. - I am asserting if a move was not caught. The program fails to run
on either ldc or dmd. To me, this makes perfect sense as for the way D
is built. In essence, opAssign isn't guaranteed to run. Feel free to
build a struct where that assert passes to convince me.
Here is the flaw in your logic:
void opAssign(Tracker rhs)
rhs is passed by value. This means that already at the point opAssign is
called, rhs *already* has a different address than the one it was passed
in with. I did not follow your logic on why this isn't so, but I don't
see how you can make it not so without changing the ABI quite drastically.
Shachar
More information about the Digitalmars-d
mailing list