On 10/18/18 2:59 PM, Manu wrote:
On Thu, Oct 18, 2018 at 7:20 AM Steven Schveighoffer via Digitalmars-d
<digitalmars-d@puremagic.com> wrote:

On 10/18/18 10:11 AM, Simen Kjærås wrote:
      a.increment(); // unsafe, non-shared method call
}

When a.increment() is being called, you have no idea if anyone else is
using the shared interface.

I do, because unless you have cast the type to shared, I'm certain there
is only thread-local aliasing to it.

No, you can never be sure. Your assumption depends on the *user*
engaging in an unsafe operation (the cast), and correctly perform a
conventional act; they must correctly the safely transfer ownership.

Not at all. No transfer of ownership is needed, no cast is needed. If you want to share something declare it shared.

My proposal puts all requirements on the author, not the user. I think
this is a much more trustworthy relationship, and in terms of
cognitive load, author:users is a 1:many relationship, and I place the
load on the '1', not the 'many.

Sure, but we can create a system today where smart people make objects that do the right thing without compiler help. We don't need to break the guarantees of shared to do it.

-Steve

Reply via email to