plans for macros
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 15 10:57:55 PDT 2008
Yes, but turning on debug levels is a compile-time thing. Many times, you
want to log based on a run-time decision, i.e. a command line switch.
Your solution does not work in this case.
-Steve
"boyd" wrote
I use nearly that exact syntax in my project:
debug Log(5, "blar", 10.0f);
The Log function is built using a simple template:
void Log(T...)(T t)
{
writefln(t);
}
As far as syntax goes that's in my opinion pretty nice. And the function
isn't even called if debug is off. You can easily adapt it to work with
debug levels:
debug(3){
Log(whatever);
Log(somethingElse);
}
So, this is in my opinion a problem that doesn't really need macro's to
solve it.
Cheers,
Boyd
More information about the Digitalmars-d-learn
mailing list