www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Compile Time Printing

reply "Blake Anderton" <rbanderton gmail.com> writes:
So from what I've found searching the newsgroup and my own 
experimentation, the best way to accomplish compile time printing 
is to do something like this:

string ctMain()
    //evaluate and return the final result string

enum result = ctMain();
pragma(msg, result);

I'm not a fan of having to build a single string and print it all 
at once. I know it's not that bad but it just means I have to 
pass around an Appender!string to all my logic functions that 
print results instead of having a central function they can call. 
I know a ctwriteln never really caught on, and pragma(msg, ...) 
has some limitations in that it can't use "local" variables even 
in CTFE. Are there any alternatives I'm overlooking?
Jan 30 2012
parent bearophile <bearophileHUGS lycos.com> writes:
Blake Anderton:

 I know a ctwriteln never really caught on,
There is an open pull request about it. And I think we'll have it in D. A problem is, that "ctwriteln" too adds a newline... :-( Bye, bearophile
Jan 30 2012