"H. S. Teoh" <[email protected]> wrote in message news:[email protected]... > > It's my fault. I really should be using module globals for those > regexes, and a module ctor (static this) for initializing them. >
In most cases, I've come to prefer lazy initalization (via a module-level @property) over module ctors because: 1. If it never actually gets used, you avoid adding extra processing at startup merely because you imported some module. 2. It decreases the risk of hitting the dreaded cyclic-module-dependency error (major PITA). And if you do want to throw away #1 and force initialization upon startup, you can still do that by simply accessing it at the beginning of main. I've always felt module ctors were a great idea, but after hitting the cyclic dependency issue enough times (or even just the first time), I've come to think they're, unfortunately, best avoided.
