http://d.puremagic.com/issues/show_bug.cgi?id=4458
--- Comment #7 from bearophile_h...@eml.cc 2011-02-28 10:36:27 PST --- > 1. fixing calls to printf falls outside of the scope of D. I use printf often in D because writeln is template-heavy (see the size of the compilation or the asm code produced by a hello world with writeln), printf is necessary if you want to debug writeln or you want to see if it's buggy, and because (as I have shown in past) printf is usually much faster than writeln when I have to print lot. > 2. the big problems printf has are simply not there with writef. The remaining issue (compile time vs runtime error) is small enough to be not worth a language feature customized for it I don't agree it's small enough. The problem is that languages like Python are dynamic, when you run them you have the source code, etc. In D you may have just an already compiled binary. Being format strings dynamically typed you have the worst of both worlds: the downsides of dynamic typing (unexpected errors at run-time) with the need to compile and maybe even unavailability of source code. Most format strings are known at compile-time, so the compiler is supposed to catch such errors at compile time. GCC and Clang do it, in most cases. > 2. such a feature would lockstep the compiler to a specific library implementation of writef, which is outside of the scope of the core language. A way to solve this is to introduce pluggable static systems, that means some functions written in D in Phobos that perform the compile-time tests on the first argument of certain write/printf functions, if such value is known at compile-time. A temporary work-around (that doesn't work for printf is to rename functions like writefln into longer names, and replace writef/writefln with two template functions that takes the format string as first template argument, perform the compile-time tests and then (to reduce template bloat) call the normal writefln that now have longer names. But this causes some template bloat that's absent with the pluggable type systems solution. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------