Very limited shared promotion

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Jun 22 21:08:14 UTC 2019


On Saturday, June 22, 2019 2:52:33 PM MDT Timon Gehr via Digitalmars-d 
wrote:
> On 22.06.19 22:32, Jonathan M Davis wrote:
> > As long as @safe code doesn't actually benefit from the implicit
> > conversion to scope shared, it makes no sense to me to have it happen.
> > The entire point is for it to be used with @trusted stuff. And if
> > that's the case, then why not just have the cast be explicit and
> > @trusted like it normally would be?
> Why would @safe code not benefit? Manu's use case is @safe code calling
> into a @trusted library.

Because if all of the code is @safe, then the fact that it was converted to
scope shared gains you nothing. It's not really shared across threads, and
it doesn't enable any useful operations. The only time that you can do
anything extra with it is when you then have @trusted code within the @safe
code, and the @trusted code then does something like temporarily pass a
reference to another thread. And if the only time that the implicit
conversion to scope shared is actually useful is when you have @trusted
code, then why not just have the cast be explicit and @trusted?

- Jonathan M Davis





More information about the Digitalmars-d mailing list