[dmd-concurrency] Smoke test

Sean Kelly sean at invisibleduck.org
Fri Jan 8 01:48:39 PST 2010


On Jan 8, 2010, at 12:36 AM, Walter Bright wrote:
> 
> Sean Kelly wrote:
>> 
>> I feel like I'm not explaining myself very well, but that's the best I can do at the moment.  As a related issue, I have a feeling that the following is a bad idea, but I haven't come up with a good explanation for why yet, maybe simply the principle of least surprise?:
>> 
>> class C
>> {
>>    shared int x;
>> }
>> 
>> auto c = new C;
>> sendRefToAnotherThread( c ); // fails, c is local
>> sendToAnotherThread( &c.x ); // succeeds, c.x is shared
>> 
>>  
> 
> The transitivity of shared doesn't work backwards, only forwards. In other words, you can have a local pointer to shared, but no shared pointers to locals.
> 
> In yet other words, sharing is transitive, locality is not.

So where would the compiler error on the example above?


More information about the dmd-concurrency mailing list