Struct that destroys its original handle on copy-by-value
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 31 10:21:39 PDT 2015
On 07/26/2015 04:29 AM, Joseph Rushton Wakeling via Digitalmars-d-learn
wrote:
> is this design idea even feasible in principle, or just a bad
> idea from the get-go?
As I understand it, it is against one of fundamental D principles:
structs are value types where any copy can be used in place of any other.
I expect there are examples where even Phobos violates it but the struct
documentation still says so: "A struct is defined to not have an
identity; that is, the implementation is free to make bit copies of the
struct as convenient."
http://dlang.org/struct.html
> And if feasible -- how would I go about it?
Disallowing automatic copying and providing a function comes to mind.
Ali
More information about the Digitalmars-d-learn
mailing list