digitalmars.D.learn - __gshared immutable array of immutable elements
- Nicolas Sicard (5/5) Nov 12 2013 In this declaration (tango.io.Console.d from Tango2):
- =?UTF-8?B?TWFydGluIERyYcWhYXI=?= (10/15) Nov 12 2013 Hi,
- Dicebot (5/7) Nov 12 2013 It is redundant because "immutable" is transitive. "immutable
- Nicolas Sicard (4/12) Nov 12 2013 That´s what I thought. So no hidden subtlety here, just
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
Nov 12 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? ThanksHi, 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
Nov 12 2013
On Tuesday, 12 November 2013 at 20:09:57 UTC, Martin Drašar wrote:Those two immutables are not redundant, because it is an array of immutable chars (string), that is itself immutable.It is redundant because "immutable" is transitive. "immutable char[]" is equivalent. But Tango has lot of meaningless and redundant attributes ( "final private" ;) )
Nov 12 2013
On Tuesday, 12 November 2013 at 20:16:31 UTC, Dicebot wrote:On Tuesday, 12 November 2013 at 20:09:57 UTC, Martin Drašar wrote:That´s what I thought. So no hidden subtlety here, just hyperprotection :) ThanksThose two immutables are not redundant, because it is an array of immutable chars (string), that is itself immutable.It is redundant because "immutable" is transitive. "immutable char[]" is equivalent. But Tango has lot of meaningless and redundant attributes ( "final private" ;) )
Nov 12 2013