Walter Bright wrote:
Doing lazy initialization certainly works, but it would require all static member access to go through a check for initialization, first. The cost of this check persists for a statically compiled language; for a JITted language like C# the access can be rewritten to remove the check.

Yeah, I figured that was going to be the stumbling block.

Is it possible for the compiler to figure out an order of execution during compile instead? Then it could simply use that to order construction instead of import/lexical ordering and there would be no runtime cost.

I expect this either isn't possible or falls into the 'possible up to a point' category.

R

Reply via email to