template debuging

JS js.mdnq at gmail.com
Thu Jul 18 05:38:12 PDT 2013


On Thursday, 18 July 2013 at 11:51:57 UTC, bearophile wrote:
> JS:
>
>> Right now I have to use an immutable bool for debug which is a 
>> global toggle...
>
> Aren't debug and version = id or version = number enough?
>
> Bye,
> bearophile

No, unless I litter the code with them(if I get what your 
saying). I don't want to whole program pragma output, just local 
pragma output.

I use static if (_MyLibrary_DEBUG) pragma(msg, txt) in my 
templates for debug output.

But I can only set _MyLibrary_DEBUG but not toggle it in code.

e.g.,

immutable _MyLibrary_DEBUG = false;

template T(string x) { enum T = x; static if (_MyLibrary_DEBUG) 
pragma(msg, T); }

T!("A");
_MyLibrary_DEBUG = true;
T!("B");
_myLibrary_DEBUG = false;
T!("C");



Only the pragma output of T!("B") should output.


More information about the Digitalmars-d-learn mailing list