[dmd-concurrency] tail-shared by default?

Walter Bright walter at digitalmars.com
Fri Jan 8 21:43:42 PST 2010



Steve Schveighoffer wrote:
> ----- Original Message ----
>
>   
>> From: Walter Bright <walter at digitalmars.com>
>>
>> Tail-shared doesn't work as soon as classes come into the picture (or 
>> any reference types).
>>     
>
> class C
> {}
>
> void foo()
> {
>    shared C c = new shared(C);
> }
>
> In my scheme, c is tail-shared.  All reference types, including pointers and class references, are tail-shared (note the subject line).  The only exception is shared global data.
>
>   

I hate to say it, but that simply doesn't work in any consistent manner. 
Types must be composable, with composable properties. Having types 
dependent on where they are declared is a pending disaster (what about 
type aliases, template type parameters, etc.?). Having no way to specify 
that c itself is shared is a disaster (how would you compose a C* ? 
Where does the shared go?).

I've been down this path before. It doesn't work. I learned my lesson 
<g>. I know it's not obvious why it fails, which is why I spent so much 
time trying to make it work.


More information about the dmd-concurrency mailing list