plans for macros

boyd gaboonviper at
Thu May 15 11:39:21 PDT 2008

What about just adding an if statement-within this kind of template?  
Wouldn't that suffice?

Using the ',' instead of concatenation can prevent a lot of complicated  
string functions. The only difference between that and macro's would be  
the function call and putting the objects on the stack. Basically the only  
advantage of macros would be that the function call is inlined.


On Thu, 15 May 2008 19:57:55 +0200, Steven Schveighoffer  
<schveiguy at> wrote:

> 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

Using Opera's revolutionary e-mail client:

More information about the Digitalmars-d-learn mailing list