I wish all qualifiers were revisited with an eye for simplification
IGotD-
nise at nise.com
Thu Aug 13 19:22:29 UTC 2020
On Sunday, 2 August 2020 at 20:50:14 UTC, Andrei Alexandrescu
wrote:
>
> * Nobody - probably not even Timon - knows what "shared" does
> or is supposed to do and not do. The most I got from Walter
> ever is "shared is intentionally restricted so you can't do
> much without a cast". Yet the definition of "much" and the
> conditions under which casting is legit are not anywhere to be
> found.
>
Shouldn't shared just be a relaxation in compiler checks so that
any data that has the "shared" qualifier is allowed to be shared
between threads. This is pretty much what __gshared is about. For
the compiler to check if you really can share the data is
currently impossible with current compiler technology. It can be
atomic integers, Intel TSX, some very elaborate lockless
algorithm, lockless COW, even mutexes/spinlocks if necessary.
Programmer must "manually" ensure that the data can be shared,
there is no other way.
So yes, a revisit of the qualifiers should be done so that they
can be precisely defined.
More information about the Digitalmars-d
mailing list