Walter Bright Wrote: > Max Samukha wrote: > > Lazy initialization requires some kind of synchronization when a is > > shared. Static initialization does not have that drawback. > > That's correct (otherwise you have the double checked locking bug). > > Wrapping the function body in a synchronized statement will do the trick. > > (Yes, it's slower.)
The issue is that we need it in a performance critical part of QtD. The library mixes in static constructors to initialise user-defined classes. This means that we can't use it when user code is in cyclic dependency. static constructors are very useful, but giving a possibility to override it's current behaviour would make them applicable to more use-cases(if you look into that bug report, another person was trying to use them exactly as we do, and faced the same problems).
