Sharing in D

Jason House jason.james.house at gmail.com
Fri Aug 1 06:40:05 PDT 2008


Walter Bright Wrote:

> Jason House wrote:
> > Walter Bright Wrote:
> > 
> >> http://www.reddit.com/comments/6u7k0/sharing_in_d/
> > 
> > This is one of my 3 big wishes for the D language.
> > 
> > The artical talks about shared being transitive just like
> > const/invariant. I certainly hope it's more like pure than transitive
> > invariant.
> 
> Pure doesn't apply to data types, it applies to functions. I don't know 
> what you mean.


Let's say I have an object that was originally written assuming non-shared access and contains one member function with no arguments.  Some later coder comes by and decides it'd be nice to share this object among threads and creates a shared instance of it.

There's no way to know if calling the member function is safe.  Maybe it accesses a non-shared global variable.  Maybe a call to an encapsulated object's member function uses a non-shared global variable.  The maintainer must be extremely careful and scour the code to ensure there's no accidental sharing that was not intended.

Maybe I'm reading too much into stuff again, but the article did say "The proposal is to make accidental sharing impossible".



More information about the Digitalmars-d mailing list