digitalmars.D - Why is the identifier "printf" known by the frontend?
- Wolfgang Draxinger (13/13) Oct 26 2006 Until now I always imported std.stdio to get printf, but today I
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/13) Oct 26 2006 It is known: digitalmars.D.bugs/763
- Wolfgang Draxinger (6/7) Oct 26 2006 Ah, thanks for the heads up.
- Walter Bright (5/7) Oct 26 2006 Because I find it verrryy handy in writing minimal test cases. writefln,...
- Wolfgang Draxinger (19/24) Oct 26 2006 Honestly: I don't like it. And the function prototype is so
- BCS (3/11) Oct 26 2006 Could this be put under a compiler switch?
- Frits van Bommel (5/19) Oct 26 2006 Or just -debug=PhobosDebug (or whatever).
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/12) Oct 27 2006 But the "import std.c.stdio;" isn't so very hard to type either ?
Until now I always imported std.stdio to get printf, but today I compiled a program where I forgot that, so fwrite, fread and the other std.c.stdio functions were missing. But not printf; obviously it is made avaliable by the compiler, which I don't understand, since eventually you don't want to use printf in your programs (for whatever reason) or want to implement a alternative. What is the reason for that? "import std.stdio" is not a real difficult thing to type. Wolfgang Draxinger -- E-Mail address works, Jabber: hexarith jabber.org, ICQ: 134682867 GPG key FP: 2FC8 319E C7D7 1ADC 0408 65C6 05F5 A645 1FD3 BD3E
Oct 26 2006
Wolfgang Draxinger wrote:Until now I always imported std.stdio to get printf, but today I compiled a program where I forgot that, so fwrite, fread and the other std.c.stdio functions were missing. But not printf; obviously it is made avaliable by the compiler, which I don't understand, since eventually you don't want to use printf in your programs (for whatever reason) or want to implement a alternative.It's in object.d. And that's a bug.What is the reason for that? "import std.stdio" is not a real difficult thing to type.It is known: digitalmars.D.bugs/763 --anders
Oct 26 2006
Anders F Bj=C3=B6rklund wrote:It is known: digitalmars.D.bugs/763Ah, thanks for the heads up. Wolfgang Draxinger --=20 E-Mail address works, Jabber: hexarith jabber.org, ICQ: 134682867 GPG key FP: 2FC8 319E C7D7 1ADC 0408 65C6 05F5 A645 1FD3 BD3E
Oct 26 2006
Wolfgang Draxinger wrote:What is the reason for that? "import std.stdio" is not a real difficult thing to type.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.
Oct 26 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 jabber.org, ICQ: 134682867 GPG key FP: 2FC8 319E C7D7 1ADC 0408 65C6 05F5 A645 1FD3 BD3E
Oct 26 2006
Walter Bright wrote:Wolfgang Draxinger wrote:Could this be put under a compiler switch? -dbg compiler debug modeWhat is the reason for that? "import std.stdio" is not a real difficult thing to type.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.
Oct 26 2006
BCS wrote:Walter Bright wrote:Or just -debug=PhobosDebug (or whatever). No compiler modifications necessary. Of course, this should be turned off for the Phobos binary distributed with the compiler.Wolfgang Draxinger wrote:Could this be put under a compiler switch? -dbg compiler debug modeWhat is the reason for that? "import std.stdio" is not a real difficult thing to type.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.
Oct 26 2006
Walter Bright wrote:But the "import std.c.stdio;" isn't so very hard to type either ? It's not so much about the usage of good ole printf, as it is about the placement of printf in the "object.d" file. But you knew that... --andersWhat is the reason for that? "import std.stdio" is not a real difficult thing to type.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.
Oct 27 2006