[dmd-concurrency] draft 7

Robert Jacques sandford at jhu.edu
Mon Feb 1 16:26:29 PST 2010


On Mon, 01 Feb 2010 17:11:57 -0500, Andrei Alexandrescu  
<andrei at erdani.com> wrote:

> Robert Jacques wrote:
>> Scope needs to prevent escaping to any scope, which most importantly  
>> includes other scope variables. i.e.:
>>  shared int[] x;
>> int[] y;
>> swap(x,y);
>>  Causes a unshared array to become shared.
>
> That won't typecheck for other reasons.
>
> There might be an issue, but the above doesn't describe it.

Okay. The problem I see is that a local version of T and a shared version  
of T might be swapped, which would cause local data to escape its thread.  
The problem is that scope doesn't know anything about the scope it  
contains, so it can't say whether assignment between the two is valid.  
It's similar to const; const doesn't know if it is mutable or immutable,  
so it takes a conservative view (no-mutation). Where as scope doesn't know  
if something is local or shared, so it has to take the conservative view  
(no-assignment/escapes)



More information about the dmd-concurrency mailing list