__gshared immutable array of immutable elements

Martin Drašar drasar at ics.muni.cz
Tue Nov 12 11:47:06 PST 2013


Dne 12.11.2013 19:49, Nicolas Sicard napsal(a):
> In this declaration (tango.io.Console.d from Tango2):
>
> __gshared immutable immutable(char)[] Eol = "\r\n";
>
> Aren't the two `immutable` keywords redundant? Why would `__gshared` be
> necessary for such an immutable type?
>
> Thanks

Hi,

this declaration is equal to

__gshared immutable string Eol = "\r\n";

Those two immutables are not redundant, because it is an array of 
immutable chars (string), that is itself immutable.

The __gshared should not be necessary, but given some quirks with type 
system and concurrency, it may be necessary to have it. But this is just 
a guess from me.

Drasha


More information about the Digitalmars-d-learn mailing list