Theoretical Best Practices
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 17 04:52:51 PDT 2015
On 8/14/15 6:25 PM, DarthCthulhu wrote:
> On Friday, 14 August 2015 at 12:40:08 UTC, Steven Schveighoffer wrote:
>>
>> I would do it this way:
>>
>> // at module level
>> debug(logging) {
>> Logger logger;
>> static this() { logger = new Logger;}
>> }
>>
>>
> By 'module level', I assume you mean in the module that defines the
> Logger class? An 'import debug.logger' or somesuch would then give all
> relevant modules access, correct?
I mean, in global scope (which is defined as being part of the module).
Not inside a class/struct/function.
> Is the compiler smart enough to compile out all the symbols associated
> with the logger if it is never instantiated?
If it's never instantiated, and it's a template, then it will not be
compiled in.
If it's not a template, it could potentially make it into the binary.
-Steve
More information about the Digitalmars-d-learn
mailing list