thisExePath purity

crimaniak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 20 12:14:08 PDT 2016


On Tuesday, 20 September 2016 at 04:26:05 UTC, Jonathan M Davis 
wrote:
> On Tuesday, September 20, 2016 04:17:21 crimaniak via 
> Digitalmars-d-learn wrote:
>>          static shared immutable ReturnType!T value;
>
> I would point out that immutable is implicitly shared, so 
> there's no reason to put shared on an immutable variable. 
> However, you _do_ want to put shared on a static constructor 
> that initializes an immutable variable so that it's only run 
> once for the program instead of once per thread (the compiler 
> really should enforce that, but there's a longstanding bug that 
> allows you to reinitialize an immutable variable by not putting 
> shared on the static constructor and starting multiple threads).
  Ok, I got it. Thanks.


More information about the Digitalmars-d-learn mailing list