www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - A possible replacement for pragma(msg,...)

Here I have reported some bugs/problems of pragma(msg,...):

At the bottom I have added a small proposal too:

D2 programs have better and better CTFE, so the need for good enough printing
is growing.

So I suggest to add a special printing function that works in the same way both
at compile-time in CTFE and at runtime. To keep things simple it can just print
a string (literal or inside a variable) and it does NOT print a newline.

It can be used in a loop too, in CTFE too, to print many things (so it's
different from a pragma(msg,...):

string foo(int i) {
    foreach (i, 0 .. 10)

Note that it's a true function, so there is no need for {}.

"ctputs" is just one of the possible names of this function.

Once such function is present, the pragma(msg,...) can probably be removed from
the language.

Mar 13 2010