On 2/22/16 9:58 AM, Danni Coy via Digitalmars-d wrote:
That worked however it seems that you can only do the assignments
within the shared static this() and not from functions called by the
initialiser which might change how I do things


This is true. The compiler wants to be super-sure that you are only setting it once.

However, this can be alleviated by changing how you do things. Factor out the code that sets it, and have it instead return a value. Then you can do this:

shared static this() {
   num_triggers = myCrazyFunction();
}

Of course, myCrazyFunction must not depend on any other static variables, as those might not be initialized.

startup initialization can be very tricky.

-Steve

Reply via email to