D-Programming-Language/dmd — pull request #692 by kennytm (2012-02-03 19:49:44+00:00)
Title: Bug 3952d: __ctfeWriteln (supersedes #296)

(This is equivalent to #296, except that I have rebased the changes on top of the master HEAD again. Please see #296 for more comments.)

----

Make DMD recognize the `__ctfeWriteln` function at interpret-time, and print the arguments to console when used.

**Note: D-Programming-Language/druntime#52 need to be pulled as well.**

For example, the code

```d
bool x() {
foreach (i; 0 .. 4)
__ctfeWriteln(i, "^^2 == ", i*i);
return true;
}
enum _ = x();
```

will print

0^^2 == 0
1^^2 == 1
2^^2 == 4
3^^2 == 9

when compiling.

This is **not** a replacement of `pragma(msg)`.

----

(BTW, Phobos's `writeln` can still behave like #237 by adding a CTFE version:

```d
void writeln(T...)(T x) {
if (__ctfe)
__ctfeWriteln(x);
else
stdout.write(x, '\n');
}
```

)