Shared

Dominikus Dittes Scherkl dominikus at scherkl.de
Thu May 16 10:17:15 UTC 2019


On Wednesday, 15 May 2019 at 09:33:19 UTC, Jonathan M Davis wrote:
> You can't forbid references to the same data. All that would be 
> required would be something like
>
> shared foo = new shared(Foo)(42);
> auto bar = foo;
Meep. This is either a compile error outside locked block (cannot 
read shared) or bar would be scope (it's lifetime will end after 
lock block is left).

> and you have two references to the same object without doing 
> anything unsafe. You could also have stuff like
>
> shared baz = foo.getBaz();
This will be forced to a copy of the returned value, not a 
reference.



More information about the Digitalmars-d mailing list