On 10/28/2012 02:46 AM, Peter Sommerfeld wrote:
> But I wonder why I
> have do declare the variables shared if the data are declared
> to be shared. Is that a shortcoming of the current compiler ?

I had to look this one up. According to the spec, a shared struct does not mean that the variables of that struct are automatically shared. It means that the members of the struct are shared:

  http://dlang.org/struct.html#ConstStruct

Here is a test:

import std.stdio;

shared struct S
{
    int i;
    int[] a;
}

void main()
{
    auto s = S();
    writeln(typeid(s));
    writeln(typeid(s.i));
    writeln(typeid(s.a));
}

According to the output, the members are shared, not the struct:

deneme.S
shared(int)
shared(shared(int)[])

> BTW: Thanks for your book! It is of great help for beginners
> like me!
>
> Peter

Thank you very much. It is really great to hear. :)

Ali

--
D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html

Reply via email to