// a.d
module a;
claas A {
        static myTemplate!A app;

        static this() {
                app = new myTemplate!A;
        }
}

void startup(State s){
        s.app = A.app;
}

// b.d
main(){
        State mainState = new State;

        startup(mainState);
}

The first problem I have is, that I can set a breakpoint on the static constructor but it's never executed. Later on startup() is executed but A.app is NULL. Why is the static constructor not run? I added a shared too, but same problem.

What I want to achieve is, that one instance of A is created on program start-up in a way that I can later use it. Or what's the best practice to instantiate at least one object of a class at startup?

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

Reply via email to