shared - i need it to be useful

Manu turkeyman at gmail.com
Thu Oct 18 18:59:28 UTC 2018


On Thu, Oct 18, 2018 at 7:20 AM Steven Schveighoffer via Digitalmars-d
<digitalmars-d at 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.
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.



More information about the Digitalmars-d mailing list