<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat., 22 Jun. 2019, 9:40 am Walter Bright via Digitalmars-d, <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 6/21/2019 5:07 AM, Manu wrote:<br>
> There is no "between threads" unless you have already entered @trusted land.<br>
> The reason for my proposal in the OP is precisely to prevent passing<br>
> data to other threads, that's the key that makes this promotion safe.<br>
<br>
Scope doesn't do that. I keep saying this. But the premise is strange, anyway, <br>
as why would you want to convert a reference to shared if not to bass it to <br>
another thread?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Because it's safe to do from the calling scope's perspective, and that's the needed entry vector into a @trusted solution.</div><div dir="auto"><br></div><div dir="auto">It is also useful too in some cases to reduce needlessly overloading methods which have a threadsafe implementation.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Can you show how you managed to get a ref to another thread without<br>
> entering @trusted?<br>
There's no such thing as a ref to another thread. You can pass a ref to another <br>
thread in a scope function, as long as the ref doesn't survive the scope of foo().<br>
<br>
The compiler cannot check that, though, and so cannot bless the implicit <br>
conversion to shared. I've said this 4 or 5 times now.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Compiler is not required to check the users work in @trusted code. It assumes the user conformed with language requirements.</div></div>