January 30, 2012 Compile Time Printing | ||||
---|---|---|---|---|
| ||||
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? |
January 30, 2012 Re: Compile Time Printing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blake Anderton | 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
|
Copyright © 1999-2021 by the D Language Foundation