Why is the identifier "printf" known by the frontend?

Wolfgang Draxinger wdraxinger at darkstargames.de
Thu Oct 26 12:28:33 PDT 2006


Walter Bright wrote:

> Because I find it verrryy handy in writing minimal test cases.
> writefln, in order to work, requires much of D and Phobos to be
> working properly. printf, being part of the C library, doesn't
> require any of Phobos and very little of D to work, so it's
> handy when things are broken.

Honestly: I don't like it.  And the function prototype is so
simple that it's written down with ease it you really need it.

int printf(char*, ...);

The problem I have with it, that printf is not really a keyword
like in say scripting languages like python. It's part of the C
stdio library, but on some systems not gauranteed to be really
there. I admit that it's oftenly handy to have a quick hands on
print for debugging. But it should really be considered, if it
wasn't better to use some more D specific concept then. And in
some situations you don't even have printf avaliable. E.g. my 3D
engine has something compareable to pty of Unix, to which
consoles, message output and so on can be sent to. For an
ordinary printf it would not be clear, where so send it (well
stdout, but this can be redirected anywhere).

Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith at jabber.org, ICQ: 134682867
GPG key FP: 2FC8 319E C7D7 1ADC 0408 65C6 05F5 A645 1FD3 BD3E



More information about the Digitalmars-d mailing list