CTFE writeln again (__ctfeWriteln)

bearophile bearophileHUGS at lycos.com
Sun Aug 7 14:56:18 PDT 2011


KennyTM~:

> So I go for my 2nd alternative, which is to add a magic function __ctfeWriteln 
> that does the same.
> 
> In my implementation, __ctfeWriteln will print the interpreted arguments 
> to stdmsg when CTFE-ed, and is a no-op in runtime (it can be configured 
> to throw an exception or actually print the arguments or anything you like).

Important: if there is a single function then I do *not* want it to print a newline. Adding a newline when you need it is much simpler than removing it if you do not want it. If you really want a newline too, then create two functions, (similar to write and writeln), but the most important is the one without newline.

What's the purpose of the two leading underscores? I prefer it without them. This is supposed to be a clean and nice function, not an unsafe ugly thing :-) So I think a "ctfeWrite" name is better.

Generally I'd like this functions to print equally at compile-time and run-time, but I see there are some problems in doing this...

If the function"ctfeWrite" becomes too much complex (to print arbitrary things), then for me it's acceptable it to print just strings too (with no newline added).

Bye and thank you for your work,
bearophile


More information about the Digitalmars-d mailing list