constructing module level immutable variables at runtime?

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 21 23:29:31 PST 2016


Am 22.02.2016 um 08:27 schrieb Danni Coy via Digitalmars-d:
> On Mon, Feb 22, 2016 at 5:09 PM, Sönke Ludwig
> <digitalmars-d at puremagic.com> wrote:
>>
>> This actually works already, if you use "shared static this". "static this"
>> is invoked for each thread that is started, thus it would overwrite the
>> existing value of num_triggers, potentially multiple times.
>
> module config;
>
> shared static this ()
> {
>      num_triggers = 1024;
> }
>
> private:
> immutable(int) num_triggers = void;
>
> is not working for me with dmd 2.070
>

I was wrong, there is obviously a language/compiler bug here. It 
compiles if you remove the "= void", but it does so for "shared static 
this" as well as for "static this". It really shouldn't in the latter case.


More information about the Digitalmars-d mailing list