shared - i need it to be useful

Steven Schveighoffer schveiguy at gmail.com
Wed Oct 17 13:40:55 UTC 2018


On 10/17/18 8:02 AM, Timon Gehr wrote:
> Now, if a class has only shared members, that is another story. In this 
> case, all references should implicitly convert to shared. There's a DIP 
> I meant to write about this. (For all qualifiers, not just shared).

When you say "shared members", you mean all the data is shared too or 
just the methods are shared?

If not the data, D has a problem with encapsulation. Not only all the 
methods on the class must be shared, but ALL code in the entire module 
must be marked as using a shared class instance. Otherwise, other 
functions could modify the private data without using the proper synch 
mechanisms.

We are better off requiring the cast, or enforcing that one must use a 
shared object to begin with.

I think any sometimes-shared object is in any case going to benefit from 
parallel implementations for when the thing is unshared.

-Steve


More information about the Digitalmars-d mailing list