Skip to content

[Discussion] Do we need =sink operator at all? #13003

@cooldome

Description

@cooldome

While working on #13002 I had this weird idea that I want to share. It is possible that we don't need =sink operator at all. It doesn't mean we will not move objects. I suggest we will replace =sink with the combination of the following three operations:

=destroy(dest)  # avoidable if we can prove that it is first assignment to dest
memCopy(dest, source)
wasMoved(source)   # avoidable if we can prove that source can't be double freed

Therefore =sink will always mean bitwise shallow copy. In old days sink operator contained an if statement that checked if it is self assignment. It is now gone it is done outside. Compiler also takes the liberty of replacing =sink calls with bitwise copy when it likes it. Possibly we can just simplify the stack and do bitwise copy in all cases.

It is easy to prove that I am wrong just provide one counter example that will not work without =sink operator.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions