Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1
deadalnix
deadalnix at gmail.com
Tue Mar 16 22:30:27 UTC 2021
On Tuesday, 16 March 2021 at 09:14:58 UTC, Walter Bright wrote:
> Postblit's problems arose from it not having access to both
> objects. The opAssign does have access to both, and the
> qualifiers can be applied to both parameters, so I don't see a
> barrier to it working.
>
YES!
This is why it is unsuitable for copies. During a copy, there are
2 objects.
Any solution, that provide to objects when moving, a situation
where only one object exists, will just open a can of worm of the
same nature as postblit for copies opened.
This is self evident. This is so obvious that I don't know how to
unpack it any further.
Pretend you have one object when you have two => problems.
Pretend you have two objects when you have one => problems.
> An opAssign gives the implementer complete control over the
> operation of it, including when and how destruction takes place
> of the original destination's contents.
That break all the invariant provided by the ctor/dtor mechanism
and because struct are composable (you can use structs as member
of structs) then the mess is not bounded to the one struct you
are toying with.
More information about the Digitalmars-d
mailing list